-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor edmCheckClassVersion
#45610
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
FWCore/Reflection/test/dumpClassVersion_reference_afterUpdate.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"edm::Wrapper<edmtest::reflection::IntObject>": { | ||
"checksum": 536952283, | ||
"version": 4 | ||
}, | ||
"edmtest::reflection::IntObject": { | ||
"checksum": 2954816125, | ||
"version": 3 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/bash -e | ||
|
||
SCRAM_TEST_NAME=TestFWCoreReflectionClassVersionUpdate | ||
rm -rf $SCRAM_TEST_NAME | ||
mkdir $SCRAM_TEST_NAME | ||
cd $SCRAM_TEST_NAME | ||
|
||
# Create a new CMSSW dev area and build modified DataFormats/TestObjects in it | ||
NEW_CMSSW_BASE=$(/bin/pwd -P)/$CMSSW_VERSION | ||
scram -a $SCRAM_ARCH project $CMSSW_VERSION | ||
pushd $CMSSW_VERSION/src | ||
|
||
# Copy FWCore/Reflection code to be able to edit it to make ROOT header parsing to fail | ||
for DIR in ${CMSSW_BASE} ${CMSSW_RELEASE_BASE} ${CMSSW_FULL_RELEASE_BASE} ; do | ||
if [ -d ${DIR}/src/FWCore/Reflection ]; then | ||
mkdir FWCore | ||
cp -Lr ${DIR}/src/FWCore/Reflection FWCore/ | ||
break | ||
fi | ||
done | ||
if [ ! -e FWCore/Reflection ]; then | ||
echo "Failed to symlink FWCore/Reflection from local or release area" | ||
exit 1; | ||
fi | ||
|
||
# The original src/ tree is protected from writes in PR tests | ||
chmod -R u+w FWCore/Reflection/test/stubs | ||
|
||
# Modify the IntObject class to trigger a new version | ||
# | ||
# Just setting USER_CXXFLAGS for scram is not sufficient,because | ||
# somehow ROOT (as used by edmCheckClassVersion) still picks up the | ||
# version 3 of the class | ||
echo "#define FWCORE_REFLECTION_TEST_INTOBJECT_V4" | cat - FWCore/Reflection/test/stubs/TestObjects.h > TestObjects.h.tmp | ||
mv TestObjects.h.tmp FWCore/Reflection/test/stubs/TestObjects.h | ||
|
||
|
||
#Set env and build in sub-shel | ||
(eval $(scram run -sh) ; scram build -j $(nproc)) | ||
|
||
popd | ||
|
||
# Prepend NEW_CMSSW_BASE's lib/src paths in to LD_LIBRARY_PATH and ROOT_INCLUDE_PATH | ||
export LD_LIBRARY_PATH=${NEW_CMSSW_BASE}/lib/${SCRAM_ARCH}:${LD_LIBRARY_PATH} | ||
export ROOT_INCLUDE_PATH=${NEW_CMSSW_BASE}/src:${ROOT_INCLUDE_PATH} | ||
|
||
# Make the actual test | ||
echo "Initial setup complete, now for the actual test" | ||
XMLPATH=${SCRAM_TEST_PATH}/stubs | ||
LIBFILE=libFWCoreReflectionTestObjects.so | ||
|
||
function die { echo Failure $1: status $2 ; exit $2 ; } | ||
function runFailure { | ||
$1 -l ${LIBFILE} -x ${XMLPATH}/$2 > log.txt && die "$1 for $2 did not fail" 1 | ||
grep -q "$3" log.txt | ||
RET=$? | ||
if [ "$RET" != "0" ]; then | ||
echo "$1 for $2 did not contain '$3', log is below" | ||
cat log.txt | ||
exit 1 | ||
fi | ||
} | ||
|
||
echo "edmCheckClassVersion tests" | ||
|
||
runFailure edmCheckClassVersion classes_def.xml "error: class 'edmtest::reflection::IntObject' has a different checksum for ClassVersion 3. Increment ClassVersion to 4 and assign it to checksum 2954816125" | ||
runFailure edmCheckClassVersion test_def_v4.xml "error: for class 'edmtest::reflection::IntObject' ROOT says the ClassVersion is 3 but classes_def.xml says it is 4. Are you sure everything compiled correctly?" | ||
|
||
edmCheckClassVersion -l ${LIBFILE} -x ${XMLPATH}/classes_def.xml -g || die "edmCheckClassVersion -g failed" $? | ||
diff -u ${XMLPATH}/test_def_v4.xml classes_def.xml.generated || die "classes_def.xml.generated differs from expectation" $? | ||
|
||
|
||
echo "edmDumpClassVersion tests" | ||
|
||
edmDumpClassVersion -l ${LIBFILE} -x ${XMLPATH}/classes_def.xml -o dump.json | ||
diff -u ${SCRAM_TEST_PATH}/dumpClassVersion_reference_afterUpdate.json dump.json || die "Unexpected class version dump" $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<lcgdict> | ||
<class name="edmtest::reflection::IntObject" ClassVersion="4"> | ||
<version ClassVersion="4" checksum="2954816125"/> | ||
<version ClassVersion="3" checksum="427917710"/> | ||
</class> | ||
<class name="edm::Wrapper<edmtest::reflection::IntObject>"/> | ||
</lcgdict> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smuzaffar Another question on test dependencies. Is it possible for a test to declare a dependence on a library that is defined in the same
BuildFile.xml
(i.e.FWCoreReflectionTestObjects
in this case)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@makortel , yes by adding
<lib name="FWCoreReflectionTestObjects"/>
in the <test .... > ` blockThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah wait, this works for
<bin .../>
but let me check if it works for<test...../>
tooThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, currently
<test ..../>
does not treat<lib name="SomeLocalLib"/>
properly but it can be easily fixed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!