Makefile: Fix TEST_LDFLAGS gcc cmdline position
PATCH 1/2 Makefile: Fix TEST_LDFLAGS gcc cmdline position
Fixes,
...
alimon@blackbox:~/upstream/ptest-runner2$ make CC=gcc check gcc -std=gnu99 -pedantic -Wall -Werror -I . -g -c tests/main.c -o tests/main.o gcc -std=gnu99 -pedantic -Wall -Werror -I . -g -c tests/ptest_list.c -o tests/ptest_list.o gcc -std=gnu99 -pedantic -Wall -Werror -I . -g -c tests/utils.c -o tests/utils.o gcc -lm -lrt -lpthread tests/main.o tests/ptest_list.o tests/utils.o utils.o ptest_list.o -o ptest-runner-test -lcheck -lsubunit -lutil /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libcheck.a(check.o): in function `tcase_create': (.text+0x1b3): undefined reference to `floor' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libcheck.a(check.o): in function `tcase_set_timeout': (.text+0x66b): undefined reference to `floor' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libcheck.a(check.o): in function `check_get_clockid': (.text+0xd03): undefined reference to `timer_create' /usr/bin/ld: (.text+0xd25): undefined reference to `timer_delete' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libcheck.a(check_pack.o): in function `ppack': (.text+0x4fc): undefined reference to `__pthread_register_cancel' /usr/bin/ld: (.text+0x546): undefined reference to `__pthread_unregister_cancel' /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libcheck.a(check_run.o): in function `srunner_run_tagged': (.text+0xbf7): undefined reference to `timer_create' /usr/bin/ld: (.text+0xc3c): undefined reference to `timer_settime' /usr/bin/ld: (.text+0xc6c): undefined reference to `timer_delete' collect2: error: ld returned 1 exit status make: *** [Makefile:39: ptest-runner-test] Error 1 ...
Signed-off-by Aníbal Limón <[email protected]>
--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
@@ -36,7 +36,7 @@ $(EXECUTABLE): $(OBJECTS) tests: $(TEST_SOURCES) $(TEST_EXECUTABLE) $(TEST_EXECUTABLE): $(TEST_OBJECTS) - $(CC) $(LDFLAGS) $(TEST_LDFLAGS) $(TEST_OBJECTS) -o $@ $(TEST_LIBSTATIC) + $(CC) $(LDFLAGS) $(TEST_OBJECTS) -o $@ $(TEST_LIBSTATIC) $(TEST_LDFLAGS) check: $(TEST_EXECUTABLE) ./$(TEST_EXECUTABLE) -d $(TEST_DATA)
Signature · 1 line
2.26.0
PATCH 2/2 Add support to specify multiple folder for ptest-runner
Enables multiple folders in -d option the current use case is to be able specify multilib folders in the same run.
The -d option allows directories without whitespaces inside, example to run after compile:
$ ./ptest-runner -d "test/data tests/data2/"
[YOCTO #12604]
Signed-off-by Aníbal Limón <[email protected]>
--- main.c | 91 ++++++++++++++++++++++----------- ptest_list.c | 17 ++++++ ptest_list.h | 1 + tests/data2/go/ptest/run-ptest | 3 ++ tests/data2/lua/ptest/run-ptest | 3 ++ utils.h | 4 +- 6 files changed, 87 insertions(+), 32 deletions(-) create mode 100755 tests/data2/go/ptest/run-ptest create mode 100755 tests/data2/lua/ptest/run-ptest
main.c +60 -31
@@ -47,10 +47,43 @@static inline void print_usage (FILE *stream,char *progname) { -fprintf (stream,"Usage: %s [-d directory] [-e exclude] [-l list] [-t timeout]" +fprintf (stream,"Usage: %s [-d directory directory2 ...] [-e exclude] [-l list] [-t timeout]" " [-x xml-filename] [-h] [ptest1 ptest2 ...]\n" , progname); } +static char ** +str2array (char *str,const char *delim,int *num) +{ +char *c, *tok; +char **array; +int i; + + c = str; + *num =1 ; +while (*c) { +if (isspace (*c)) + (*num)++; + c++; + } + + + array =malloc ((size_t )*num *sizeof (char **)); +CHECK_ALLOCATION (array,1 ,1 ); + + i =0 ; + tok =strtok_r (str, delim, &c); + array[i] =strdup (tok); +CHECK_ALLOCATION (array[i],1 ,1 ); + i++; +while ((tok =strtok_r (NULL ," " , &c)) !=NULL ) { + array[i] =strdup (tok); +CHECK_ALLOCATION (array[i],1 ,1 ); + i++; + } + +return array; +} +int main (int argc,char *argv[]) {
@@ -59,7 +92,6 @@ main(int argc, char *argv[])int i;int rc;int ptest_exclude_num =0 ; -char *c, *tok;#ifdef MEMCHECK mtrace ();
@@ -68,7 +100,11 @@ main(int argc, char *argv[])struct ptest_list *head, *run;struct ptest_options opts; - opts.directory =strdup (DEFAULT_DIRECTORY ); + opts.dirs =malloc (sizeof (char **) *1 ); +CHECK_ALLOCATION (opts.dirs,1 ,1 ); + opts.dirs[0 ] =strdup (DEFAULT_DIRECTORY ); +CHECK_ALLOCATION (opts.dirs[0 ],1 ,1 ); + opts.dirs_no =1 ; opts.exclude =NULL ; opts.list =0 ; opts.timeout =DEFAULT_TIMEOUT ;
@@ -78,34 +114,12 @@ main(int argc, char *argv[])while ((opt =getopt (argc, argv,"d:e:lt:x:h" )) !=-1 ) {switch (opt) {case 'd' : -free (opts.directory); - opts.directory =realpath (optarg,NULL ); -CHECK_ALLOCATION (opts.directory,1 ,1 ); +free (opts.dirs[0 ]); +free (opts.dirs); + opts.dirs =str2array (optarg," " , &(opts.dirs_no));break ;case 'e' : - c = optarg; - ptest_exclude_num =1 ; - -while (*c) { -if (isspace (*c)) - ptest_exclude_num++; - c++; - } - - - opts.exclude =malloc ((size_t )ptest_exclude_num *sizeof (char )); -CHECK_ALLOCATION (opts.exclude,1 ,1 ); - - i =0 ; - tok =strtok_r (optarg," " , &c); - opts.exclude[i] =strdup (tok); -CHECK_ALLOCATION (opts.exclude[i],1 ,1 ); - i++; -while ((tok =strtok_r (NULL ," " , &c)) !=NULL ) { - opts.exclude[i] =strdup (tok); -CHECK_ALLOCATION (opts.exclude[i],1 ,1 ); - i++; - } + opts.exclude =str2array (optarg," " , &ptest_exclude_num);break ;case 'l' : opts.list =1 ;
@@ -140,10 +154,25 @@ main(int argc, char *argv[]) } } - head =get_available_ptests (opts.directory); + head =NULL ; +for (i =0 ; i < opts.dirs_no; i ++) { +struct ptest_list *tmp; + + tmp =get_available_ptests (opts.dirs[i]); +if (tmp ==NULL ) { +fprintf (stderr,PRINT_PTESTS_NOT_FOUND_DIR , opts.dirs[i]); +continue ; + } + + +if (head ==NULL ) + head = tmp; +else + head =ptest_list_extend (head, tmp); + }if (head ==NULL ||ptest_list_length (head) ==0 ) {fprintf (stderr,PRINT_PTESTS_NOT_FOUND ); -return 1 ; +return 1 ; }if (opts.list) {
ptest_list.c +17 -0
@@ -216,3 +216,20 @@ ptest_list_remove(struct ptest_list *head, char *ptest, int free)return p; } + +struct ptest_list * +ptest_list_extend (struct ptest_list *head,struct ptest_list *extend) +{ +struct ptest_list *p, *q; + +VALIDATE_PTR_RNULL (head); +VALIDATE_PTR_RNULL (extend); + +for (p = head; p->next !=NULL ; p = p->next); + q = extend->next; + p->next = q; + +free (extend); + +return head; +}
ptest_list.h +1 -0
@@ -64,5 +64,6 @@ extern struct ptest_list *ptest_list_search(struct ptest_list *, char *);extern struct ptest_list *ptest_list_search_by_file (struct ptest_list *,char *,struct stat );extern struct ptest_list *ptest_list_add (struct ptest_list *,char *,char *);extern struct ptest_list *ptest_list_remove (struct ptest_list *,char *,int ); +extern struct ptest_list *ptest_list_extend (struct ptest_list *,struct ptest_list *);#endif // PTEST_RUNNER_LIST_H
tests/data2/go/ptest/run-ptest new file +3 -0
@@ -0,0 +1,3 @@ +#!/bin/sh + +echo "go"
tests/data2/lua/ptest/run-ptest new file +3 -0
@@ -0,0 +1,3 @@ +#!/bin/sh + +echo "lua"
utils.h +3 -1
@@ -27,13 +27,15 @@#include "ptest_list.h" #define PRINT_PTESTS_NOT_FOUND "No ptests found.\n" +#define PRINT_PTESTS_NOT_FOUND_DIR "Warning: ptests not found in, %s.\n"#define PRINT_PTESTS_AVAILABLE "Available ptests:\n"#define CHECK_ALLOCATION (p, size, exit_on_null) \ check_allocation1(p, size, __FILE__, __LINE__, exit_on_null)struct ptest_options { -char *directory; +char **dirs; +int dirs_no;char **exclude;int list;int timeout;
Signature · 1 line
2.26.0