Skip to content

Commit 53e182c

Browse files
committed
Check crash probe privacy
Signed-off-by: Alex Jaramillo <[email protected]>
1 parent 44d423a commit 53e182c

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

tests/check_privacy.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* This program is part of the Clear Linux Project
3+
*
4+
* Copyright 2025 Intel Corporation
5+
*
6+
* This program is free software; you can redistribute it and/or modify it under
7+
* the terms and conditions of the GNU Lesser General Public License, as
8+
* published by the Free Software Foundation; either version 2.1 of the License,
9+
* or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope it will be useful, but WITHOUT ANY
12+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13+
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14+
* details.
15+
*/
16+
17+
#include <check.h>
18+
19+
20+
START_TEST(test_add) {
21+
int result = add(2, 3);
22+
ck_assert_int_eq(result, 5); // Check if the result is as expected
23+
}
24+
END_TEST
25+
26+
Suite *example_suite(void) {
27+
Suite *s;
28+
TCase *tc_core;
29+
30+
s = suite_create("Example");
31+
tc_core = tcase_create("Core");
32+
33+
tcase_add_test(tc_core, test_add); // Add the test case to the test suite
34+
suite_add_tcase(s, tc_core);
35+
36+
return s;
37+
}
38+
39+
int main(void) {
40+
int number_failed;
41+
Suite *s;
42+
SRunner *sr;
43+
44+
s = example_suite();
45+
sr = srunner_create(s);
46+
47+
srunner_run_all(sr, CK_NORMAL);
48+
number_failed = srunner_ntests_failed(sr);
49+
srunner_free(sr);
50+
51+
return (number_failed == 0) ? 0 : 1; // Return 0 if all tests pass
52+
}

tests/local.mk

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ check_PROGRAMS = \
1818
%D%/check_postd \
1919
%D%/check_probes \
2020
%D%/check_journal \
21-
%D%/check_libtelemetry
21+
%D%/check_libtelemetry \
22+
%D%/check_privacy
2223

2324
dist_check_SCRIPTS = \
2425
%D%/create-core.sh
@@ -191,6 +192,7 @@ endif
191192
@CHECK_CFLAGS@
192193
%C%_check_libtelemetry_LDADD = \
193194
@CHECK_LIBS@ \
195+
src/nica/nc-string.c \
194196
$(top_builddir)/src/libtelemetry.la \
195197
$(top_builddir)/src/libtelem-shared.la
196198

@@ -201,6 +203,23 @@ if LOG_SYSTEMD
201203
endif
202204
endif
203205

206+
%C%_check_privacy_SOURCES = \
207+
src/util.c \
208+
src/telemetry.c \
209+
src/configuration.c \
210+
src/probes/crash_probe.c \
211+
src/nica/nc-string.c \
212+
src/nica/hashmap.c \
213+
src/nica/inifile.c
214+
215+
%C%_check_privacy_CFLAGS = \
216+
$(AM_CFLAGS) \
217+
-lelf -ldw \
218+
@CHECK_CFLAGS@
219+
220+
%C%_check_privacy_LDADD = \
221+
@CHECK_LIBS@
222+
204223
@VALGRIND_CHECK_RULES@
205224
VALGRIND_SUPPRESSIONS_FILES = %D%/telemetrics-client.supp
206225
VALGRIND_FLAGS = \

0 commit comments

Comments
 (0)