Skip to content

Commit c03a7f1

Browse files
committed
Add a dlopen test for toggle traces
1 parent ac964aa commit c03a7f1

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

integration_tests/toggle.bats

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ get_unique_jobid() {
1414
}
1515

1616
@test "toggle_api" {
17-
rm -rf toggle_traces 2>/dev/null
18-
1917
cc ${THAPI_INCFLAGS} ./integration_tests/toggle.c -o toggle ${THAPI_LDFLAGS}
2018

19+
rm -rf toggle_traces 2>/dev/null
2120
iprof --trace-output toggle_traces --no-analysis -- ./toggle
2221
dir=$(ls -d -1 ./toggle_traces/*/)
2322

@@ -37,6 +36,12 @@ get_unique_jobid() {
3736
auto_stop_count=$(babeltrace_thapi -c $dir | grep lttng_ust_toggle:auto_stop | wc -l)
3837
[ "$auto_stop_count" -eq 1 ]
3938

39+
rm -rf toggle_traces 2>/dev/null
40+
iprof --trace-output toggle_traces --no-analysis -- ./toggle
41+
dir=$(ls -d -1 ./toggle_traces/*/)
42+
43+
auto_stop_count=$(babeltrace_thapi -c $dir | grep lttng_ust_toggle:auto_stop | wc -l)
44+
[ "$auto_stop_count" -eq 1 ]
4045
}
4146

4247
toggle_count_base() {

integration_tests/toggle.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1+
#include <dlfcn.h>
2+
#include <stdlib.h>
3+
14
#include <thapi.h>
25

36
int main(int argc, char *argv[]) {
7+
int dlopen_test = (argc > 1 ? atoi(argv[1]): 0);
8+
if (!dlopen_test) goto regular_test;
9+
10+
void *self = dlopen(NULL, RTLD_LAZY);
11+
if (!self) return 1;
12+
dlclose(self);
13+
14+
regular_test:
415
thapi_start();
516
thapi_stop();
17+
18+
return 0;
619
}

0 commit comments

Comments
 (0)