Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Utilities/ReleaseScripts/test/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<test name="TestSCRAM" command="run.sh"/>
<test name="SCRAM_TestPass" command="true"/>
<test name="SCRAM_TestFail" command="! false"/>
<test name="test-gdb-python" command="gdb/test-gdb-python.sh">
<use name="gdb"/>
</test>
<test name="test-cmsTraceFunction-setenv" command="gdb/test-cmsTraceFunction-setenv.sh">
<use name="gdb"/>
</test>
<test name="test-clang-tidy" command="test-clang-tidy.sh">
<use name="llvm"/>
</test>
Expand Down
26 changes: 26 additions & 0 deletions Utilities/ReleaseScripts/test/gdb/test-cmsTraceFunction-setenv.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <iostream>
#include <cstdlib>
#include <stdlib.h>

class ScheduleItems {
public:
ScheduleItems() {}
void initMisc();
};

void ScheduleItems::initMisc() { std::cout << "ScheduleItems::initMisc() called" << std::endl; }

void my_setenv(const char* env, const char* value) {
setenv(env, value, 1);
std::cout << "setenv() called" << std::endl;
std::cout << env << "=" << std::getenv(env) << std::endl;
}

int main() {
my_setenv("FOO", "1");
ScheduleItems obj;
obj.initMisc();
my_setenv("FOO", "2");
my_setenv("FOO", "3");
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -ex
g++ -o test-cmsTraceFunction-setenv $(dirname $0)/test-cmsTraceFunction-setenv.cpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of $(dirname $0)/ is not immediately clear to me, given that the following line uses ./.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As scram runs unit tests from $CMSSW_BASE/unittests/<test_name> directory, so $0 will be full path to test-cmsTraceFunction-setenv.sh and $(dirname $0) should be $CMSSW_BASE/src/Utilities/ReleaseScripts/test/gdb . Other option is to use ${ SCRAM_TEST_PATH}/gdb but then unit test can only run via scram b runtests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the options specified the source file, not the target binary. Thanks, and never mind.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A post-merge question: do we explicitly depend on g++ elsewhere in CMSSW already? I'm just wondering the hypothetical case we'd some day change our compiler.

cmsTraceFunction --startAfterFunction ScheduleItems::initMisc setenv ./test-cmsTraceFunction-setenv 2>&1 | grep setenv > setenv.log
rm -f test-cmsTraceFunction-setenv
setenv_count=$(grep '^setenv() called' setenv.log | wc -l)
break_setenv=$(grep 'Breakpoint .* in setenv ()' setenv.log | wc -l)
if [ ${setenv_count} != 3 ] || [ ${break_setenv} != 2 ] ; then
exit 1
fi
10 changes: 10 additions & 0 deletions Utilities/ReleaseScripts/test/gdb/test-gdb-python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -ex
gdb_python=$(gdb -q -ex 'python exec("import sys;print(sys.executable)")' -ex quit)
cmssw_python=$(scram tool tag python3 PYTHON3_BASE)/bin
cmssw_python=$(realpath ${cmssw_python})/python
if [ "${gdb_python}" != "${cmssw_python}" ] ; then
echo "python used by GDB and CMSSW are not same"
exit 1
else
echo "CMSSW/GDB python OK"
fi