Debian Codegraph @

tools/discoverer.c

raw symbols SCIP
1 #cxx . . $ `<file>/tools/discoverer.c`/include "discoverer.h"cxx . . $ `<file>/tools/discoverer.h`/
2
3 #include "io.h"cxx . . $ `<file>/tools/io.h`/
4
5 #include <string.h>
6 #include <stdbool.h>
7 #include <stdlib.h>
8
9 #include <cgreen/internal/unit_implementation.h>cxx . . $ `<file>/include/cgreen/internal/unit_implementation.h`/
10
11 #include "../src/utils.h"cxx . . $ `<file>/src/utils.h`/
12
13
14 #include "test_item.h"cxx . . $ `<file>/tools/test_item.h`/
15
16 static const char *cgreen_spec_start_ofcxx . . $ cgreen_spec_start_of(fb58d2e09a2a1ce6).(const char *line) {
17 return strstrcxx . . $ strstr(a713fe7b9a57cf96).(line, CGREEN_SPEC_PREFIXcxx . . $ `include/cgreen/internal/unit_implementation.h:29:9`! CGREEN_SEPARATORcxx . . $ `include/cgreen/internal/unit_implementation.h:30:9`!);
18 }
19
20 static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! contains_cgreen_speccxx . . $ contains_cgreen_spec(c5f7da30cbc0f4e9).(const char *line) {
21 return cgreen_spec_start_ofcxx . . $ cgreen_spec_start_of(fb58d2e09a2a1ce6).(line) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
22 }
23
24 static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! is_definitioncxx . . $ is_definition(c5f7da30cbc0f4e9).(const char *line) {
25 return strstrcxx . . $ strstr(a713fe7b9a57cf96).(line, " D ") != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
26 }
27
28 static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! complete_line_readcxx . . $ complete_line_read(c6b7e35ff6de5671).(char line[]) {
29 return line[strlencxx . . $ strlen(751346f8406fd082).(line)-1] == '\n';
30 }
31
32
33 static void strip_newline_fromcxx . . $ strip_newline_from(fda57c8427c60377).(char *name) {
34 if (name[strlencxx . . $ strlen(751346f8406fd082).(name)-1] == '\n')
35 name[strlencxx . . $ strlen(751346f8406fd082).(name)-1] = '\0';
36 }
37
38 static void add_all_tests_fromcxx . . $ add_all_tests_from(7dce3a68eb7dc2a5).(FILEcxx . . $ FILE# *nm_output_pipe, CgreenVectorcxx . . $ CgreenVector# *tests, boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! verbose) {
39 char line[1000];
40 int length = read_linecxx . . $ read_line(324bcb2c939f72bd).(nm_output_pipe, line, sizeof(line)-1);
41 while (length > -1) { /* TODO: >0 ? */
42 if (!complete_line_readcxx . . $ complete_line_read(c6b7e35ff6de5671).(line))
43 PANICcxx . . $ `src/utils.h:14:9`!("Too long line in nm output");
44 if (contains_cgreen_speccxx . . $ contains_cgreen_spec(c5f7da30cbc0f4e9).(line) && is_definitioncxx . . $ is_definition(c5f7da30cbc0f4e9).(line)) {
45 strip_newline_fromcxx . . $ strip_newline_from(fda57c8427c60377).(line);
46 TestItemcxx . . $ TestItem# *test_item = create_test_item_fromcxx . . $ create_test_item_from(4b4482ac30013e03).(cgreen_spec_start_ofcxx . . $ cgreen_spec_start_of(fb58d2e09a2a1ce6).(line));
47 if (verbose)
48 printfcxx . . $ printf(581fddd72a8db8fc).("Discovered %s:%s (%s)\n", test_item->context_namecxx . . $ test_item#context_name., test_item->test_namecxx . . $ test_item#test_name.,
49 test_item->specification_namecxx . . $ test_item#specification_name.);
50 cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(tests, test_item);
51 }
52 length = read_linecxx . . $ read_line(324bcb2c939f72bd).(nm_output_pipe, line, sizeof(line)-1);
53 }
54 }
55
56 CgreenVectorcxx . . $ CgreenVector# *discover_tests_incxx . . $ discover_tests_in(58480c4ec9f8c8d).(const char *filename, boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! verbose) {
57 FILEcxx . . $ FILE# *library = open_filecxx . . $ open_file(82ec0787cd37e0a3).(filename, "r");
58 if (library == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!)
59 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
60 close_filecxx . . $ close_file(89bc1efcdac0ca22).(library);
61
62 char nm_command[1000];
63 sprintfcxx . . $ sprintf(26c8642d26409d6d).(nm_command, "%s '%s' 2>&1", NM_EXECUTABLEcxx . . $ `<built-in>:418:9`!, filename);
64 FILEcxx . . $ FILE# *nm_output_pipe = open_processcxx . . $ open_process(82ec0787cd37e0a3).(nm_command, "r");
65 if (nm_output_pipe == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!)
66 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
67
68 CgreenVectorcxx . . $ CgreenVector# *tests = create_cgreen_vectorcxx . . $ create_cgreen_vector(940ca2d138a76a1b).((GenericDestructorcxx . . $ GenericDestructor#)&destroy_test_itemcxx . . $ destroy_test_item(ca46adf33924622e).);
69 add_all_tests_fromcxx . . $ add_all_tests_from(7dce3a68eb7dc2a5).(nm_output_pipe, tests, verbose);
70 close_processcxx . . $ close_process(89bc1efcdac0ca22).(nm_output_pipe);
71
72 return tests;
73 }