mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
Merge pull request #27493 from poettering/generate-sym-test-tweaks
fixes/additions for generate-sym-test
This commit is contained in:
commit
c19b827802
|
@ -40,6 +40,8 @@ print('''/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
''')
|
||||
|
||||
for header in sys.argv[3:]:
|
||||
|
@ -51,10 +53,11 @@ print('''
|
|||
''')
|
||||
|
||||
print('''
|
||||
static const struct {
|
||||
struct symbol {
|
||||
const char *name;
|
||||
const void *symbol;
|
||||
} symbols_from_sym[] = {''')
|
||||
};
|
||||
static struct symbol symbols_from_sym[] = {''')
|
||||
|
||||
with open(sys.argv[1], "r") as f:
|
||||
process_sym_file(f)
|
||||
|
@ -64,15 +67,25 @@ print(''' {}
|
|||
|
||||
for dirpath, _, filenames in os.walk(sys.argv[2]):
|
||||
for filename in filenames:
|
||||
if not filename.endswith(".c") and not filename.endswith(".h"):
|
||||
continue
|
||||
with open(os.path.join(dirpath, filename), "r") as f:
|
||||
process_source_file(f)
|
||||
|
||||
print(''' {}
|
||||
};
|
||||
|
||||
static int sort_callback(const void *a, const void *b) {
|
||||
const struct symbol *x = a, *y = b;
|
||||
return strcmp(x->name, y->name);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
size_t i, j;
|
||||
|
||||
qsort(symbols_from_sym, sizeof(symbols_from_sym)/sizeof(symbols_from_sym[0])-1, sizeof(symbols_from_sym[0]), sort_callback);
|
||||
qsort(symbols_from_source, sizeof(symbols_from_source)/sizeof(symbols_from_source[0])-1, sizeof(symbols_from_source[0]), sort_callback);
|
||||
|
||||
puts("From symbol file:");
|
||||
for (i = 0; symbols_from_sym[i].name; i++)
|
||||
printf("%p: %s\\n", symbols_from_sym[i].symbol, symbols_from_sym[i].name);
|
||||
|
@ -85,5 +98,17 @@ int main(void) {
|
|||
printf("Found %zu symbols from symbol file.\\n", i);
|
||||
printf("Found %zu symbols from source files.\\n", j);
|
||||
|
||||
for (i = 0; symbols_from_sym[i].name; i++) {
|
||||
struct symbol*n = bsearch(symbols_from_sym+i, symbols_from_source, sizeof(symbols_from_source)/sizeof(symbols_from_source[0])-1, sizeof(symbols_from_source[0]), sort_callback);
|
||||
if (!n)
|
||||
printf("Found in symbol file, but not in sources: %s\\n", symbols_from_sym[i].name);
|
||||
}
|
||||
|
||||
for (j = 0; symbols_from_source[j].name; j++) {
|
||||
struct symbol*n = bsearch(symbols_from_source+j, symbols_from_source, sizeof(symbols_from_sym)/sizeof(symbols_from_sym[0])-1, sizeof(symbols_from_sym[0]), sort_callback);
|
||||
if (!n)
|
||||
printf("Found in sources, but not in symbol file: %s\\n", symbols_from_source[i].name);
|
||||
}
|
||||
|
||||
return i == j ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}''')
|
||||
|
|
Loading…
Reference in a new issue