Introduce structure for shell tests
v5 cover Introduce structure for shell tests
Hi maintainers,
This revision of series of patches continues the effort of upstreaming a perftool-testsuite and incorporates the review feedback that was previously discussed.
A new patch (7/7) was added to fix the incorrect relative path for locating stderr-whitelist.txt in report tests.
Thanks,
Jakub
Link to v4: https://lore.kernel.org/linux-perf-users/[email protected]/#t
Changes since v4:
Patch 1: applied review feedback, renamed shell_info -> shell_test_info, minor cleanups Patch 2: renamed shell_info -> shell_test_info
Patch 4: renamed shell_info -> shell_test_info
Patch 7: added in v5, fix for relative path to
stderr-whitelist.txt in report tests
Jakub Brnak (7):
perf tests: Create a structure for shell tests perf test: Provide setup for the shell test suite
perftool-testsuite: Add empty setup for base_probe perf test: Introduce storing logs for shell tests perf test: Format log directories for shell tests perf test: Remove perftool drivers
perf test: Fix relative path for 'stderr-whitelist.txt'
tools/perf/tests/builtin-test.c | 129 +++++++- tools/perf/tests/shell/base_probe/setup.sh | 13 + .../tests/shell/base_report/test_basic.sh | 6 +- .../tests/shell/perftool-testsuite_probe.sh | 24 -- .../tests/shell/perftool-testsuite_report.sh | 23 -- tools/perf/tests/tests-scripts.c | 288 +++++++++++++++--- tools/perf/tests/tests-scripts.h | 15 + tools/perf/tests/tests.h | 8 +- 8 files changed, 398 insertions(+), 108 deletions(-) create mode 100755 tools/perf/tests/shell/base_probe/setup.sh delete mode 100755 tools/perf/tests/shell/perftool-testsuite_probe.sh delete mode 100755 tools/perf/tests/shell/perftool-testsuite_report.sh
Signature · 1 line
2.51.1
PATCH v5 1/7 perf tests: Create a structure for shell tests
The general structure of test suites with test cases has been implemented for C tests for some time, while shell tests were just all put into a list without any possible structuring.
Provide the same possibility of test suite structure for shell tests. The suite is created for each subdirectory located in the 'perf/tests/shell' directory that contains at least one test script. All of the deeper levels of subdirectories will be merged with the first level of test cases. The name of the test suite is the name of the subdirectory, where the test cases are located. For all of the test scripts that are not in any subdirectory, a test suite with a single test case is created as it has been till now.
The new structure of the shell tests for 'perf test list':
77: build id cache operations
78: coresight
78:1: CoreSight / ASM Pure Loop
78:2: CoreSight / Memcpy 16k 10 Threads
78:3: CoreSight / Thread Loop 10 Threads - Check TID 78:4: CoreSight / Thread Loop 2 Threads - Check TID 78:5: CoreSight / Unroll Loop Thread 10
79: daemon operations
80: perf diff tests
--- tools/perf/tests/tests-scripts.c | 251 +++++++++++++++++++++++++------ tools/perf/tests/tests-scripts.h | 5 + 2 files changed, 209 insertions(+), 47 deletions(-)
tools/perf/tests/tests-scripts.c +204 -47
@@ -151,14 +151,64 @@ static char *strdup_check(const char *str)return newstr; } -static int shell_test__run (struct test_suite *test,int subtest__maybe_unused ) +/* Check if dirent entry is a directory using file descriptor, handling DT_UNKNOWN case */ +static bool is_directory_fd (int dir_fd,struct dirent *ent) { -const char *file = test->priv; +struct stat st; + +if (ent->d_type ==DT_DIR ) +return true; + +if (ent->d_type !=DT_UNKNOWN ) +return false; + +/* Need to stat the file to determine if it's a directory */ +if (fstatat (dir_fd, ent->d_name, &st,0 ) !=0 ) +return false; + +return S_ISDIR (st.st_mode); +} + +/* Free the whole structure of test_suite with its test_cases */ +static void free_suite (struct test_suite *suite) +{ +if (suite->test_cases) { +int num =0 ; + +while (suite->test_cases[num].name) {/* Last case has name set to NULL */ +free ((void *) suite->test_cases[num].name); +free ((void *) suite->test_cases[num].desc); + num++; + } +free (suite->test_cases); + } +if (suite->desc) +free ((void *) suite->desc); +if (suite->priv) { +struct shell_test_info *test_info = suite->priv; + +free ((void *) test_info->base_path); +free (test_info); + } + +free (suite); +} + +static int shell_test__run (struct test_suite *test,int subtest) +{ +const char *file;int err;char *cmd =NULL ; +/* Get absolute file path */ +if (subtest >=0 ) + file = test->test_cases[subtest].name; +else /* Single test case */ + file = test->test_cases[0 ].name; +if (asprintf (&cmd,"%s%s" , file, verbose ?" -v" :"" ) <0 )return TEST_FAIL ; + err =system (cmd);free (cmd);if (!err)
@@ -167,65 +217,112 @@ static int shell_test__run(struct test_suite *test, int subtest __maybe_unused)return WEXITSTATUS (err) ==2 ?TEST_SKIP :TEST_FAIL ; } -static void append_script (int dir_fd,const char *name,char *desc, -struct test_suite ***result, -size_t *result_sz) +static struct test_suite *prepare_test_suite (int dir_fd) { -char filename[PATH_MAX ], link[128 ]; -struct test_suite *test_suite, **result_tmp; -struct test_case *tests; +char dirpath[PATH_MAX ], link[128 ];ssize_t len; -char *exclusive; +struct test_suite *test_suite =NULL ; +struct shell_test_info *test_info; +/* Get dir absolute path */ snprintf (link,sizeof (link),"/proc/%d/fd/%d" ,getpid (), dir_fd); - len =readlink (link, filename,sizeof (filename)); + len =readlink (link, dirpath,sizeof (dirpath));if (len <0 ) {pr_err ("Failed to readlink %s" , link); -return ; +return NULL ; } - filename[len++] ='/' ; -strcpy (&filename[len], name); + dirpath[len++] ='/' ; + dirpath[len] ='\0' ; - tests =calloc (2 ,sizeof (*tests)); -if (!tests) { -pr_err ("Out of memory while building script test suite list\n" ); -return ; - } - tests[0 ].name =strdup_check (name); - exclusive =strstr (desc," (exclusive)" ); -if (exclusive !=NULL ) { - tests[0 ].exclusive = true; - exclusive[0 ] ='\0' ; - } - tests[0 ].desc =strdup_check (desc); - tests[0 ].run_case = shell_test__run; test_suite =zalloc (sizeof (*test_suite));if (!test_suite) {pr_err ("Out of memory while building script test suite list\n" ); -free (tests); -return ; +return NULL ; } - test_suite->desc = desc; - test_suite->test_cases = tests; - test_suite->priv =strdup_check (filename); + + test_info =zalloc (sizeof (*test_info)); +if (!test_info) { +pr_err ("Out of memory while building script test suite list\n" ); +return NULL ; + } + + test_info->base_path =strdup_check (dirpath);/* Absolute path to dir */ + + test_suite->priv = test_info; + test_suite->desc =NULL ; + test_suite->test_cases =NULL ; + +return test_suite; +} + +static void append_suite (struct test_suite ***result, +size_t *result_sz,struct test_suite *test_suite) +{ +struct test_suite **result_tmp; +/* Realloc is good enough, though we could realloc by chunks, not that * anyone will ever measure performance here */ result_tmp =realloc (*result, (*result_sz +1 ) *sizeof (*result_tmp));if (result_tmp ==NULL ) {pr_err ("Out of memory while building script test suite list\n" ); -free (tests); -free (test_suite); +free_suite (test_suite);return ; } +/* Add file to end and NULL terminate the struct array */ *result = result_tmp; (*result)[*result_sz] = test_suite; (*result_sz)++; } -static void append_scripts_in_dir (int dir_fd, -struct test_suite ***result, -size_t *result_sz) +static void append_script_to_suite (int dir_fd,const char *name,char *desc, +struct test_suite *test_suite,size_t *tc_count) +{ +char file_name[PATH_MAX ], link[128 ]; +struct test_case *tests; +size_t len; +char *exclusive; + +if (!test_suite) +return ; + +/* Requires an empty test case at the end */ + tests =realloc (test_suite->test_cases, (*tc_count +2 ) *sizeof (*tests)); +if (!tests) { +pr_err ("Out of memory while building script test suite list\n" ); +return ; + } + +/* Get path to the test script */ +snprintf (link,sizeof (link),"/proc/%d/fd/%d" ,getpid (), dir_fd); + len =readlink (link, file_name,sizeof (file_name)); +if (len <0 ) { +pr_err ("Failed to readlink %s" , link); +return ; + } + file_name[len++] ='/' ; +strcpy (&file_name[len], name); + +/* Get path to the script from base dir */ + tests[(*tc_count)].name =strdup_check (file_name); + tests[(*tc_count)].exclusive = false; + exclusive =strstr (desc," (exclusive)" ); +if (exclusive !=NULL ) { + tests[(*tc_count)].exclusive = true; + exclusive[0 ] ='\0' ; + } + tests[(*tc_count)].desc = desc; + tests[(*tc_count)].skip_reason =NULL ;/* Unused */ + tests[(*tc_count)++].run_case = shell_test__run; + + tests[(*tc_count)].name =NULL ;/* End the test cases */ + + test_suite->test_cases = tests; +} + +static void append_scripts_in_subdir (int dir_fd, +struct test_suite *suite, +size_t *tc_count) {struct dirent **entlist;struct dirent *ent;
@@ -244,22 +341,82 @@ static void append_scripts_in_dir(int dir_fd,char *desc =shell_test__description (dir_fd, ent->d_name);if (desc)/* It has a desc line - valid script */ -append_script (dir_fd, ent->d_name, desc, result, result_sz); +append_script_to_suite (dir_fd, ent->d_name, desc, suite, tc_count);continue ; } -if (ent->d_type !=DT_DIR ) { -struct stat st; - -if (ent->d_type !=DT_UNKNOWN ) -continue ; -fstatat (dir_fd, ent->d_name, &st,0 ); -if (!S_ISDIR (st.st_mode)) -continue ; + +if (!is_directory_fd (dir_fd, ent)) +continue ; + + fd =openat (dir_fd, ent->d_name,O_PATH ); + +/* Recurse into the dir */ +append_scripts_in_subdir (fd, suite, tc_count); + } +for (i =0 ; i < n_dirs; i++)/* Clean up */ +zfree (&entlist[i]); +free (entlist); +} + +static void append_suites_in_dir (int dir_fd, +struct test_suite ***result, +size_t *result_sz) +{ +struct dirent **entlist; +struct dirent *ent; +int n_dirs, i; + +/* List files, sorted by alpha */ + n_dirs =scandirat (dir_fd,"." , &entlist,NULL , alphasort); +if (n_dirs ==-1 ) +return ; +for (i =0 ; i < n_dirs && (ent = entlist[i]); i++) { +int fd; +struct test_suite *test_suite; +size_t cases_count =0 ; + +if (ent->d_name[0 ] =='.' ) +continue ;/* Skip hidden files */ +if (is_test_script (dir_fd, ent->d_name)) {/* It's a test */ +char *desc =shell_test__description (dir_fd, ent->d_name); + +if (desc) {/* It has a desc line - valid script */ +/* Create a test suite with a single test case */ + test_suite =prepare_test_suite (dir_fd); +append_script_to_suite (dir_fd, ent->d_name, desc, + test_suite, &cases_count); + test_suite->desc =strdup_check (desc); + +if (cases_count) +append_suite (result, result_sz, test_suite); +else /* Wasn't able to create the test case */ +free_suite (test_suite); + } +continue ; } + +if (!is_directory_fd (dir_fd, ent)) +continue ; +if (strncmp (ent->d_name,"base_" ,5 ) ==0 )continue ;/* Skip scripts that have a separate driver. */ + +/* Scan subdir for test cases*/ fd =openat (dir_fd, ent->d_name,O_PATH ); -append_scripts_in_dir (fd, result, result_sz); + test_suite =prepare_test_suite (fd);/* Prepare a testsuite with its path */ +if (!test_suite) +continue ; + +append_scripts_in_subdir (fd, test_suite, &cases_count); +if (cases_count ==0 ) { +free_suite (test_suite); +continue ; + } + +/* If no setup, set name to the directory */ + test_suite->desc =strdup_check (ent->d_name); + +append_suite (result, result_sz, test_suite);close (fd); }for (i =0 ; i < n_dirs; i++)/* Clean up */
@@ -278,7 +435,7 @@ struct test_suite **create_script_test_suites(void)* length array. */ if (dir_fd >=0 ) -append_scripts_in_dir (dir_fd, &result, &result_sz); +append_suites_in_dir (dir_fd, &result, &result_sz); result_tmp =realloc (result, (result_sz +1 ) *sizeof (*result_tmp));if (result_tmp ==NULL ) {
tools/perf/tests/tests-scripts.h +5 -0
@@ -4,6 +4,11 @@#include "tests.h" +/* Additional information attached to shell tests */ +struct shell_test_info { +const char *base_path; +}; +struct test_suite **create_script_test_suites (void );#endif /* TESTS_SCRIPTS_H */
Signature · 1 line
2.51.1
Re: [PATCH v5 1/7] perf tests: Create a structure for shell tests
Quoted 266 lines · Jakub Brnak
The general structure of test suites with test cases has been implemented for C tests for some time, while shell tests were just all put into a list without any possible structuring.
Provide the same possibility of test suite structure for shell tests. The suite is created for each subdirectory located in the 'perf/tests/shell' directory that contains at least one test script. All of the deeper levels of subdirectories will be merged with the first level of test cases. The name of the test suite is the name of the subdirectory, where the test cases are located. For all of the test scripts that are not in any subdirectory, a test suite with a single test case is created as it has been till now.
The new structure of the shell tests for 'perf test list':
77: build id cache operations
78: coresight
78:1: CoreSight / ASM Pure Loop
78:2: CoreSight / Memcpy 16k 10 Threads
78:3: CoreSight / Thread Loop 10 Threads - Check TID 78:4: CoreSight / Thread Loop 2 Threads - Check TID 78:5: CoreSight / Unroll Loop Thread 10
79: daemon operations
80: perf diff testsSigned-off-by Michael Petlan <[email protected]>Co-developed-by Veronika Molnarova <[email protected]>Signed-off-by Veronika Molnarova <[email protected]>Signed-off-by Jakub Brnak <[email protected]>--- tools/perf/tests/tests-scripts.c | 251 +++++++++++++++++++++++++------ tools/perf/tests/tests-scripts.h | 5 + 2 files changed, 209 insertions(+), 47 deletions(-)tools/perf/tests/tests-scripts.c +134
-43@@ -151,14 +151,64 @@ static char *strdup_check(const char *str)return newstr; } -static int shell_test__run (struct test_suite *test,int subtest__maybe_unused ) +/* Check if dirent entry is a directory using file descriptor, handling DT_UNKNOWN case */ +static bool is_directory_fd (int dir_fd,struct dirent *ent) { -const char *file = test->priv; +struct stat st; + +if (ent->d_type ==DT_DIR ) +return true; + +if (ent->d_type !=DT_UNKNOWN ) +return false; + +/* Need to stat the file to determine if it's a directory */ +if (fstatat (dir_fd, ent->d_name, &st,0 ) !=0 ) +return false; + +return S_ISDIR (st.st_mode); +} + +/* Free the whole structure of test_suite with its test_cases */ +static void free_suite (struct test_suite *suite) +{ +if (suite->test_cases) { +int num =0 ; + +while (suite->test_cases[num].name) {/* Last case has name set to NULL */ +free ((void *) suite->test_cases[num].name); +free ((void *) suite->test_cases[num].desc); + num++; + } +free (suite->test_cases); + } +if (suite->desc) +free ((void *) suite->desc); +if (suite->priv) { +struct shell_test_info *test_info = suite->priv; + +free ((void *) test_info->base_path); +free (test_info); + } + +free (suite); +} + +static int shell_test__run (struct test_suite *test,int subtest) +{ +const char *file;int err;char *cmd =NULL ; +/* Get absolute file path */ +if (subtest >=0 ) + file = test->test_cases[subtest].name; +else /* Single test case */ + file = test->test_cases[0 ].name; +if (asprintf (&cmd,"%s%s" , file, verbose ?" -v" :"" ) <0 )return TEST_FAIL ; + err =system (cmd);free (cmd);if (!err)@@ -167,65 +217,112 @@ static int shell_test__run(struct test_suite *test, int subtest __maybe_unused)return WEXITSTATUS (err) ==2 ?TEST_SKIP :TEST_FAIL ; } -static void append_script (int dir_fd,const char *name,char *desc, -struct test_suite ***result, -size_t *result_sz) +static struct test_suite *prepare_test_suite (int dir_fd) { -char filename[PATH_MAX ], link[128 ]; -struct test_suite *test_suite, **result_tmp; -struct test_case *tests; +char dirpath[PATH_MAX ], link[128 ];ssize_t len; -char *exclusive; +struct test_suite *test_suite =NULL ; +struct shell_test_info *test_info; +/* Get dir absolute path */ snprintf (link,sizeof (link),"/proc/%d/fd/%d" ,getpid (), dir_fd); - len =readlink (link, filename,sizeof (filename)); + len =readlink (link, dirpath,sizeof (dirpath));if (len <0 ) {pr_err ("Failed to readlink %s" , link); -return ; +return NULL ; } - filename[len++] ='/' ; -strcpy (&filename[len], name); + dirpath[len++] ='/' ; + dirpath[len] ='\0' ; - tests =calloc (2 ,sizeof (*tests)); -if (!tests) { -pr_err ("Out of memory while building script test suite list\n" ); -return ; - } - tests[0 ].name =strdup_check (name); - exclusive =strstr (desc," (exclusive)" ); -if (exclusive !=NULL ) { - tests[0 ].exclusive = true; - exclusive[0 ] ='\0' ; - } - tests[0 ].desc =strdup_check (desc); - tests[0 ].run_case = shell_test__run; test_suite =zalloc (sizeof (*test_suite));if (!test_suite) {pr_err ("Out of memory while building script test suite list\n" ); -free (tests); -return ; +return NULL ; } - test_suite->desc = desc; - test_suite->test_cases = tests; - test_suite->priv =strdup_check (filename); + + test_info =zalloc (sizeof (*test_info)); +if (!test_info) { +pr_err ("Out of memory while building script test suite list\n" ); +return NULL ; + } + + test_info->base_path =strdup_check (dirpath);/* Absolute path to dir */ + + test_suite->priv = test_info; + test_suite->desc =NULL ; + test_suite->test_cases =NULL ; + +return test_suite; +} + +static void append_suite (struct test_suite ***result, +size_t *result_sz,struct test_suite *test_suite) +{ +struct test_suite **result_tmp; +/* Realloc is good enough, though we could realloc by chunks, not that * anyone will ever measure performance here */ result_tmp =realloc (*result, (*result_sz +1 ) *sizeof (*result_tmp));if (result_tmp ==NULL ) {pr_err ("Out of memory while building script test suite list\n" ); -free (tests); -free (test_suite); +free_suite (test_suite);return ; } +/* Add file to end and NULL terminate the struct array */ *result = result_tmp; (*result)[*result_sz] = test_suite; (*result_sz)++; } -static void append_scripts_in_dir (int dir_fd, -struct test_suite ***result, -size_t *result_sz) +static void append_script_to_suite (int dir_fd,const char *name,char *desc, +struct test_suite *test_suite,size_t *tc_count) +{ +char file_name[PATH_MAX ], link[128 ]; +struct test_case *tests; +size_t len; +char *exclusive; + +if (!test_suite) +return ; + +/* Requires an empty test case at the end */ + tests =realloc (test_suite->test_cases, (*tc_count +2 ) *sizeof (*tests)); +if (!tests) { +pr_err ("Out of memory while building script test suite list\n" ); +return ; + } + +/* Get path to the test script */ +snprintf (link,sizeof (link),"/proc/%d/fd/%d" ,getpid (), dir_fd); + len =readlink (link, file_name,sizeof (file_name)); +if (len <0 ) { +pr_err ("Failed to readlink %s" , link); +return ; + } + file_name[len++] ='/' ; +strcpy (&file_name[len], name); + +/* Get path to the script from base dir */ + tests[(*tc_count)].name =strdup_check (file_name); + tests[(*tc_count)].exclusive = false; + exclusive =strstr (desc," (exclusive)" ); +if (exclusive !=NULL ) { + tests[(*tc_count)].exclusive = true; + exclusive[0 ] ='\0' ; + } + tests[(*tc_count)].desc = desc; + tests[(*tc_count)].skip_reason =NULL ;/* Unused */ + tests[(*tc_count)++].run_case = shell_test__run; + + tests[(*tc_count)].name =NULL ;/* End the test cases */ + + test_suite->test_cases = tests; +} + +static void append_scripts_in_subdir (int dir_fd, +struct test_suite *suite, +size_t *tc_count) {struct dirent **entlist;struct dirent *ent;@@ -244,22 +341,82 @@ static void append_scripts_in_dir(int dir_fd,char *desc =shell_test__description (dir_fd, ent->d_name);if (desc)/* It has a desc line - valid script */ -append_script (dir_fd, ent->d_name, desc, result, result_sz); +append_script_to_suite (dir_fd, ent->d_name, desc, suite, tc_count);continue ; } -if (ent->d_type !=DT_DIR ) { -struct stat st; - -if (ent->d_type !=DT_UNKNOWN ) -continue ; -fstatat (dir_fd, ent->d_name, &st,0 );
tools/perf/tests/tests-scripts.c static void append_scripts_in_dir(int dir_fd, · line 354
Quoted 10 lines
tools/perf/tests/tests-scripts.c +8
-2-if (!S_ISDIR (st.st_mode)) -continue ; + +if (!is_directory_fd (dir_fd, ent)) +continue ; + + fd =openat (dir_fd, ent->d_name,O_PATH ); + +/* Recurse into the dir */ +append_scripts_in_subdir (fd, suite, tc_count);
The fd opened above looks like it is leaking here.
Quoted 44 lines
tools/perf/tests/tests-scripts.c +43
-0+ } +for (i =0 ; i < n_dirs; i++)/* Clean up */ +zfree (&entlist[i]); +free (entlist); +} + +static void append_suites_in_dir (int dir_fd, +struct test_suite ***result, +size_t *result_sz) +{ +struct dirent **entlist; +struct dirent *ent; +int n_dirs, i; + +/* List files, sorted by alpha */ + n_dirs =scandirat (dir_fd,"." , &entlist,NULL , alphasort); +if (n_dirs ==-1 ) +return ; +for (i =0 ; i < n_dirs && (ent = entlist[i]); i++) { +int fd; +struct test_suite *test_suite; +size_t cases_count =0 ; + +if (ent->d_name[0 ] =='.' ) +continue ;/* Skip hidden files */ +if (is_test_script (dir_fd, ent->d_name)) {/* It's a test */ +char *desc =shell_test__description (dir_fd, ent->d_name); + +if (desc) {/* It has a desc line - valid script */ +/* Create a test suite with a single test case */ + test_suite =prepare_test_suite (dir_fd); +append_script_to_suite (dir_fd, ent->d_name, desc, + test_suite, &cases_count); + test_suite->desc =strdup_check (desc); + +if (cases_count) +append_suite (result, result_sz, test_suite); +else /* Wasn't able to create the test case */ +free_suite (test_suite); + } +continue ; } + +if (!is_directory_fd (dir_fd, ent))
tools/perf/tests/tests-scripts.c static void append_scripts_in_dir(int dir_fd, · line 407
Quoted 10 lines
tools/perf/tests/tests-scripts.c +6
-1+continue ; +if (strncmp (ent->d_name,"base_" ,5 ) ==0 )continue ;/* Skip scripts that have a separate driver. */ + +/* Scan subdir for test cases*/ fd =openat (dir_fd, ent->d_name,O_PATH ); -append_scripts_in_dir (fd, result, result_sz); + test_suite =prepare_test_suite (fd);/* Prepare a testsuite with its path */ +if (!test_suite)
As fd is open here it should be closed.
tools/perf/tests/tests-scripts.c static void append_scripts_in_dir(int dir_fd, · line 412
Quoted 5 lines
tools/perf/tests/tests-scripts.c +5
-0+continue ; + +append_scripts_in_subdir (fd, test_suite, &cases_count); +if (cases_count ==0 ) { +free_suite (test_suite);
fd should be closed here too I believe.
These are minor issues that I think Arnaldo can fix up.
Thanks,
Ian
Quoted 38 lines
tools/perf/tests/tests-scripts.c +8
-1+continue ; + } + +/* If no setup, set name to the directory */ + test_suite->desc =strdup_check (ent->d_name); + +append_suite (result, result_sz, test_suite);close (fd); }for (i =0 ; i < n_dirs; i++)/* Clean up */ @@ -278,7 +435,7 @@ struct test_suite **create_script_test_suites(void)* length array. */ if (dir_fd >=0 ) -append_scripts_in_dir (dir_fd, &result, &result_sz); +append_suites_in_dir (dir_fd, &result, &result_sz); result_tmp =realloc (result, (result_sz +1 ) *sizeof (*result_tmp));if (result_tmp ==NULL ) {tools/perf/tests/tests-scripts.h +5
-1@@ -4,6 +4,11 @@#include "tests.h" +/* Additional information attached to shell tests */ +struct shell_test_info { +const char *base_path; +}; +struct test_suite **create_script_test_suites (void );#endif /* TESTS_SCRIPTS_H */ --2.51.1
PATCH v5 2/7 perf test: Provide setup for the shell test suite
In reply to Jakub BrnakSome of the perftool-testsuite test cases require a setup to be done beforehand as may be recording data, setting up cache or restoring sample rate. The setup file also provides the possibility to set the name of the test suite, if the name of the directory is not good enough.
Check for the existence of the "setup.sh" script for the shell test suites and run it before the any of the test cases. If the setup fails, skip all of the test cases of the test suite as the setup may be required for the result to be valid.
--- tools/perf/tests/builtin-test.c | 30 +++++++++++++++++++----- tools/perf/tests/tests-scripts.c | 39 +++++++++++++++++++++++++++++--- tools/perf/tests/tests-scripts.h | 11 ++++++++- tools/perf/tests/tests.h | 8 ++++--- 4 files changed, 75 insertions(+), 13 deletions(-)
tools/perf/tests/builtin-test.c +24 -6
@@ -258,6 +258,22 @@ static test_fnptr test_function(const struct test_suite *t, int test_case)return t->test_cases[test_case].run_case; } +/* If setup fails, skip all test cases */ +static void check_shell_setup (const struct test_suite *t,int ret) +{ +struct shell_test_info *test_info; + +if (!t->priv) +return ; + + test_info = t->priv; + +if (ret ==TEST_SETUP_FAIL ) + test_info->has_setup =FAILED_SETUP ; +else if (test_info->has_setup ==RUN_SETUP ) + test_info->has_setup =PASSED_SETUP ; +} +static bool test_exclusive (const struct test_suite *t,int test_case) {if (test_case <=0 )
@@ -347,10 +363,9 @@ static int run_test_child(struct child_process *process)return -err; } -#define TEST_RUNNING -3 - -static int print_test_result (struct test_suite *t,int curr_suite,int curr_test_case, -int result,int width,int running) +static int print_test_result (struct test_suite *t,int curr_suite, +int curr_test_case,int result,int width, +int running) {if (test_suite__num_test_cases (t) >1 ) {int subw = width >2 ? width -2 : width;
@@ -367,7 +382,8 @@ static int print_test_result(struct test_suite *t, int curr_suite, int curr_testcase TEST_OK :pr_info (" Ok\n" );break ; -case TEST_SKIP : { +case TEST_SKIP : +case TEST_SETUP_FAIL :{const char *reason =skip_reason (t, curr_test_case);if (reason)
@@ -482,6 +498,7 @@ static void finish_test(struct child_test **child_tests, int running_test, int c }/* Clean up child process. */ ret =finish_command (&child_test->process); +check_shell_setup (t, ret);if (verbose >1 || (verbose ==1 && ret ==TEST_FAIL ))fprintf (stderr,"%s" , err_output.buf);
@@ -504,7 +521,8 @@ static int start_test(struct test_suite *test, int curr_suite, int curr_test_cas err =test_function (test, curr_test_case)(test, curr_test_case);pr_debug ("---- end ----\n" );print_test_result (test, curr_suite, curr_test_case, err, width, -/*running=*/ 0 ); +/*running=*/ 0 ); +check_shell_setup (test, err); }return 0 ; }
tools/perf/tests/tests-scripts.c +36 -3
@@ -138,6 +138,12 @@ static bool is_test_script(int dir_fd, const char *name)return is_shell_script (dir_fd, name); } +/* Filter for scandir */ +static int setup_filter (const struct dirent *entry) +{ +return strcmp (entry->d_name,SHELL_SETUP ); +} +/* Duplicate a string and fall over and die if we run out of memory */ static char *strdup_check (const char *str) {
@@ -196,6 +202,7 @@ static void free_suite(struct test_suite *suite)static int shell_test__run (struct test_suite *test,int subtest) { +struct shell_test_info *test_info = test->priv;const char *file;int err;char *cmd =NULL ;
@@ -206,6 +213,23 @@ static int shell_test__run(struct test_suite *test, int subtest) else /* Single test case */ file = test->test_cases[0 ].name; +/* Run setup if needed */ +if (test_info->has_setup ==RUN_SETUP ) { +char *setup_script; + +if (asprintf (&setup_script,"%s%s%s" , test_info->base_path, +SHELL_SETUP , verbose ?" -v" :"" ) <0 ) +return TEST_SETUP_FAIL ; + + err =system (setup_script); +free (setup_script); + +if (err) +return TEST_SETUP_FAIL ; + }else if (test_info->has_setup ==FAILED_SETUP ) { +return TEST_SKIP ;/* Skip test suite if setup failed */ + } +if (asprintf (&cmd,"%s%s" , file, verbose ?" -v" :"" ) <0 )return TEST_FAIL ;
@@ -247,6 +271,7 @@ static struct test_suite *prepare_test_suite(int dir_fd) } test_info->base_path =strdup_check (dirpath);/* Absolute path to dir */ + test_info->has_setup =NO_SETUP ; test_suite->priv = test_info; test_suite->desc =NULL ;
@@ -329,7 +354,7 @@ static void append_scripts_in_subdir(int dir_fd,int n_dirs, i;/* List files, sorted by alpha */ - n_dirs =scandirat (dir_fd,"." , &entlist,NULL , alphasort); + n_dirs =scandirat (dir_fd,"." , &entlist, setup_filter, alphasort);if (n_dirs ==-1 )return ;for (i =0 ; i < n_dirs && (ent = entlist[i]); i++) {
@@ -413,8 +438,16 @@ static void append_suites_in_dir(int dir_fd,continue ; } -/* If no setup, set name to the directory */ - test_suite->desc =strdup_check (ent->d_name); +if (is_test_script (fd,SHELL_SETUP )) {/* Check for setup existence */ +char *desc =shell_test__description (fd,SHELL_SETUP ); + +/* Set the suite name by the setup description */ + test_suite->desc = desc; + ((struct shell_test_info *)(test_suite->priv))->has_setup =RUN_SETUP ; + }else { +/* If no setup, set name to the directory */ + test_suite->desc =strdup_check (ent->d_name); + }append_suite (result, result_sz, test_suite);close (fd);
tools/perf/tests/tests-scripts.h +10 -1
@@ -4,9 +4,18 @@#include "tests.h" -/* Additional information attached to shell tests */ +#define SHELL_SETUP "setup.sh" + +enum shell_setup { +NO_SETUP =0 , +RUN_SETUP =1 , +FAILED_SETUP =2 , +PASSED_SETUP =3 , +}; +struct shell_test_info {const char *base_path; +enum shell_setup has_setup; };struct test_suite **create_script_test_suites (void );
tools/perf/tests/tests.h +5 -3
@@ -6,9 +6,11 @@#include "util/debug.h" enum { -TEST_OK =0 , -TEST_FAIL =-1 , -TEST_SKIP =-2 , +TEST_OK =0 , +TEST_FAIL =-1 , +TEST_SKIP =-2 , +TEST_RUNNING =-3 , +TEST_SETUP_FAIL =-4 , };#define TEST_ASSERT_VAL (text, cond) \
Signature · 1 line
2.51.1
PATCH v5 3/7 perftool-testsuite: Add empty setup for base_probe
In reply to Jakub BrnakAdd empty setup to set a proper name for base_probe testsuite, can be utilized for basic test setup for the future.
--- tools/perf/tests/shell/base_probe/setup.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 tools/perf/tests/shell/base_probe/setup.sh
tools/perf/tests/shell/base_probe/setup.sh new file +13 -0
@@ -0,0 +1,13 @@ +#!/bin/bash +# perftool-testsuite :: perf_probe +# SPDX-License-Identifier: GPL-2.0 + +# +# setup.sh of perf probe test +# Author: Michael Petlan <[email protected]> +# +# Description: +# +# Setting testsuite name, for future use +# +#
Signature · 1 line
2.51.1
PATCH v5 4/7 perf test: Introduce storing logs for shell tests
In reply to Jakub BrnakCreate temporary directories for storing log files for shell tests that could help while debugging. The log files are necessary for perftool testsuite test cases also. If the variable PERFTEST_KEEP_LOGS is set keep the logs, else delete them.
--- tools/perf/tests/builtin-test.c | 91 ++++++++++++++++++++++++++++++++ tools/perf/tests/tests-scripts.c | 3 ++ tools/perf/tests/tests-scripts.h | 1 + 3 files changed, 95 insertions(+)
tools/perf/tests/builtin-test.c +91 -0
@@ -6,6 +6,7 @@*/ #include <ctype.h> #include <fcntl.h> +#include <ftw.h> #include <errno.h> #ifdef HAVE_BACKTRACE_SUPPORT #include <execinfo.h>
@@ -282,6 +283,85 @@ static bool test_exclusive(const struct test_suite *t, int test_case)return t->test_cases[test_case].exclusive; } +static int delete_file (const char *fpath,const struct stat *sb__maybe_unused , +int typeflag,struct FTW *ftwbuf) +{ +int rv =-1 ; + +/* Stop traversal if going too deep */ +if (ftwbuf->level >5 ) { +pr_err ("Tree traversal reached level %d, stopping." , ftwbuf->level); +return rv; + } + +/* Remove only expected directories */ +if (typeflag ==FTW_D || typeflag ==FTW_DP ) { +const char *dirname = fpath + ftwbuf->base; + +if (strcmp (dirname,"logs" ) &&strcmp (dirname,"examples" ) && +strcmp (dirname,"header_tar" ) &&strncmp (dirname,"perf_" ,5 )) { +pr_err ("Unknown directory %s" , dirname); +return rv; + } + } + +/* Attempt to remove the file */ + rv =remove (fpath); +if (rv) +pr_err ("Failed to remove file: %s" , fpath); + +return rv; +} + +static bool create_logs (struct test_suite *t,int pass) +{ +bool store_logs = t->priv && ((struct shell_test_info *)(t->priv))->store_logs; + +if (pass ==1 && (!test_exclusive (t,0 ) || sequential || dont_fork)) { +/* Sequential and non-exclusive tests run on the first pass. */ +return store_logs; + }else if (pass !=1 &&test_exclusive (t,0 ) && !sequential && !dont_fork) { +/* Exclusive tests without sequential run on the second pass. */ +return store_logs; + } +return false; +} + +static char *setup_shell_logs (const char *name) +{ +char template[PATH_MAX ]; +char *temp_dir; + +if (snprintf (template,PATH_MAX ,"/tmp/perf_test_%s.XXXXXX" , name) <0 ) { +pr_err ("Failed to create log dir template" ); +return NULL ;/* Skip the testsuite */ + } + + temp_dir =mkdtemp (template); +if (temp_dir) { +setenv ("PERFSUITE_RUN_DIR" , temp_dir,1 ); +return strdup (temp_dir); + } + +pr_err ("Failed to create the temporary directory" ); + +return NULL ;/* Skip the testsuite */ +} + +static void cleanup_shell_logs (char *dirname) +{ +char *keep_logs =getenv ("PERFTEST_KEEP_LOGS" ); + +/* Check if logs should be kept or do cleanup */ +if (dirname) { +if (!keep_logs ||strcmp (keep_logs,"y" ) !=0 ) +nftw (dirname, delete_file,8 ,FTW_DEPTH |FTW_PHYS ); +free (dirname); + } + +unsetenv ("PERFSUITE_RUN_DIR" ); +} +static bool perf_test__matches (const char *desc,int suite_num,int argc,const char *argv[]) {int i;
@@ -628,6 +708,7 @@ static int __cmd_test(struct test_suite **suites, int argc, const char *argv[],for (struct test_suite **t = suites; *t; t++, curr_suite++) {int curr_test_case;bool suite_matched = false; +char *tmpdir =NULL ;if (!perf_test__matches (test_description (*t,-1 ), curr_suite, argc, argv)) {/*
@@ -657,6 +738,15 @@ static int __cmd_test(struct test_suite **suites, int argc, const char *argv[], } for (unsigned int run = 0; run < runs_per_test; run++) { + /* Setup temporary log directories for shell test suites */ + if (create_logs(*t, pass)) { + tmpdir = setup_shell_logs((*t)->desc); + + /* Couldn't create log dir, skip test suite */ + if (tmpdir == NULL) + ((struct shell_test_info *)((*t)->priv))->has_setup = + FAILED_SETUP; + } test_suite__for_each_test_case(*t, curr_test_case) { if (!suite_matched && !perf_test__matches(test_description(*t, curr_test_case),
@@ -669,6 +759,7 @@ static int __cmd_test(struct test_suite **suites, int argc, const char *argv[], goto err_out; } } +cleanup_shell_logs (tmpdir); }if (!sequential) {/* Parallel mode starts tests but doesn't finish them. Do that now. */
tools/perf/tests/tests-scripts.c +3 -0
@@ -272,6 +272,7 @@ static struct test_suite *prepare_test_suite(int dir_fd) test_info->base_path =strdup_check (dirpath);/* Absolute path to dir */ test_info->has_setup =NO_SETUP ; + test_info->store_logs = false; test_suite->priv = test_info; test_suite->desc =NULL ;
@@ -438,6 +439,8 @@ static void append_suites_in_dir(int dir_fd,continue ; } +/* Store logs for testsuite is sub-directories */ + ((struct shell_test_info *)(test_suite->priv))->store_logs = true;if (is_test_script (fd,SHELL_SETUP )) {/* Check for setup existence */ char *desc =shell_test__description (fd,SHELL_SETUP );
tools/perf/tests/tests-scripts.h +1 -0
@@ -16,6 +16,7 @@ enum shell_setup {struct shell_test_info {const char *base_path;enum shell_setup has_setup; +bool store_logs; };struct test_suite **create_script_test_suites (void );
Signature · 1 line
2.51.1
Ian Rogers
reviewerRe: [PATCH v5 4/7] perf test: Introduce storing logs for shell tests
Quoted 139 lines · Jakub Brnak
Create temporary directories for storing log files for shell tests that could help while debugging. The log files are necessary for perftool testsuite test cases also. If the variable
PERFTEST_KEEP_LOGSis set keep the logs, else delete them.Signed-off-by Michael Petlan <[email protected]>Co-developed-by Veronika Molnarova <[email protected]>Signed-off-by Veronika Molnarova <[email protected]>Signed-off-by Jakub Brnak <[email protected]>--- tools/perf/tests/builtin-test.c | 91 ++++++++++++++++++++++++++++++++ tools/perf/tests/tests-scripts.c | 3 ++ tools/perf/tests/tests-scripts.h | 1 + 3 files changed, 95 insertions(+)tools/perf/tests/builtin-test.c +90
-0@@ -6,6 +6,7 @@*/ #include <ctype.h> #include <fcntl.h> +#include <ftw.h> #include <errno.h> #ifdef HAVE_BACKTRACE_SUPPORT #include <execinfo.h> @@ -282,6 +283,85 @@ static bool test_exclusive(const struct test_suite *t, int test_case)return t->test_cases[test_case].exclusive; } +static int delete_file (const char *fpath,const struct stat *sb__maybe_unused , +int typeflag,struct FTW *ftwbuf) +{ +int rv =-1 ; + +/* Stop traversal if going too deep */ +if (ftwbuf->level >5 ) { +pr_err ("Tree traversal reached level %d, stopping." , ftwbuf->level); +return rv; + } + +/* Remove only expected directories */ +if (typeflag ==FTW_D || typeflag ==FTW_DP ) { +const char *dirname = fpath + ftwbuf->base; + +if (strcmp (dirname,"logs" ) &&strcmp (dirname,"examples" ) && +strcmp (dirname,"header_tar" ) &&strncmp (dirname,"perf_" ,5 )) { +pr_err ("Unknown directory %s" , dirname); +return rv; + } + } + +/* Attempt to remove the file */ + rv =remove (fpath); +if (rv) +pr_err ("Failed to remove file: %s" , fpath); + +return rv; +} + +static bool create_logs (struct test_suite *t,int pass) +{ +bool store_logs = t->priv && ((struct shell_test_info *)(t->priv))->store_logs; + +if (pass ==1 && (!test_exclusive (t,0 ) || sequential || dont_fork)) { +/* Sequential and non-exclusive tests run on the first pass. */ +return store_logs; + }else if (pass !=1 &&test_exclusive (t,0 ) && !sequential && !dont_fork) { +/* Exclusive tests without sequential run on the second pass. */ +return store_logs; + } +return false; +} + +static char *setup_shell_logs (const char *name) +{ +char template[PATH_MAX ]; +char *temp_dir; + +if (snprintf (template,PATH_MAX ,"/tmp/perf_test_%s.XXXXXX" , name) <0 ) { +pr_err ("Failed to create log dir template" ); +return NULL ;/* Skip the testsuite */ + } + + temp_dir =mkdtemp (template); +if (temp_dir) { +setenv ("PERFSUITE_RUN_DIR" , temp_dir,1 ); +return strdup (temp_dir); + } + +pr_err ("Failed to create the temporary directory" ); + +return NULL ;/* Skip the testsuite */ +} + +static void cleanup_shell_logs (char *dirname) +{ +char *keep_logs =getenv ("PERFTEST_KEEP_LOGS" ); + +/* Check if logs should be kept or do cleanup */ +if (dirname) { +if (!keep_logs ||strcmp (keep_logs,"y" ) !=0 ) +nftw (dirname, delete_file,8 ,FTW_DEPTH |FTW_PHYS ); +free (dirname); + } + +unsetenv ("PERFSUITE_RUN_DIR" ); +} +static bool perf_test__matches (const char *desc,int suite_num,int argc,const char *argv[]) {int i;@@ -628,6 +708,7 @@ static int __cmd_test(struct test_suite **suites, int argc, const char *argv[],for (struct test_suite **t = suites; *t; t++, curr_suite++) {int curr_test_case;bool suite_matched = false; +char *tmpdir =NULL ;if (!perf_test__matches (test_description (*t,-1 ), curr_suite, argc, argv)) {/* @@ -657,6 +738,15 @@ static int __cmd_test(struct test_suite **suites, int argc, const char *argv[], } for (unsigned int run = 0; run < runs_per_test; run++) { + /* Setup temporary log directories for shell test suites */ + if (create_logs(*t, pass)) { + tmpdir = setup_shell_logs((*t)->desc); + + /* Couldn't create log dir, skip test suite */ + if (tmpdir == NULL) + ((struct shell_test_info *)((*t)->priv))->has_setup = + FAILED_SETUP; + } test_suite__for_each_test_case(*t, curr_test_case) { if (!suite_matched && !perf_test__matches(test_description(*t, curr_test_case),
tools/perf/tests/builtin-test.c static int __cmd_test(struct test_suite **suites, int argc, const char *argv[], · line 762
Quoted 4 lines
tools/perf/tests/builtin-test.c +1
-0@@ -669,6 +759,7 @@ static int __cmd_test(struct test_suite **suites, int argc, const char *argv[], goto err_out; } } +cleanup_shell_logs (tmpdir);
Is the test log clean up happening while the tests are running in parallel?
tools/perf/tests/builtin-test.c static int __cmd_test(struct test_suite **suites, int argc, const char *argv[], · line 765
Quoted 3 lines
tools/perf/tests/builtin-test.c +0
-0}if (!sequential) {/* Parallel mode starts tests but doesn't finish them. Do that now. */
At this point we're going to wait for all the parallel tests to finish. Shouldn't cleanup_shell_logs be after the work has completed? Something like:
```
if (!sequential) {
/* Parallel mode starts tests but doesn't finish them. Do that now. */
for (size_t x = 0; x < num_tests; x++)
finish_test(child_tests, x, num_tests, width);
}
cleanup_shell_logs(tmpdir);
```Thanks,
Ian
Quoted 36 lines
tools/perf/tests/tests-scripts.c +3
-0@@ -272,6 +272,7 @@ static struct test_suite *prepare_test_suite(int dir_fd) test_info->base_path =strdup_check (dirpath);/* Absolute path to dir */ test_info->has_setup =NO_SETUP ; + test_info->store_logs = false; test_suite->priv = test_info; test_suite->desc =NULL ;@@ -438,6 +439,8 @@ static void append_suites_in_dir(int dir_fd,continue ; } +/* Store logs for testsuite is sub-directories */ + ((struct shell_test_info *)(test_suite->priv))->store_logs = true;if (is_test_script (fd,SHELL_SETUP )) {/* Check for setup existence */ char *desc =shell_test__description (fd,SHELL_SETUP );tools/perf/tests/tests-scripts.h +1
-1@@ -16,6 +16,7 @@ enum shell_setup {struct shell_test_info {const char *base_path;enum shell_setup has_setup; +bool store_logs; };struct test_suite **create_script_test_suites (void ); --2.51.1
PATCH v5 5/7 perf test: Format log directories for shell tests
In reply to Jakub BrnakThe name of the log directory can be taken from the test suite description, which possibly could contain whitespace characters. This can cause further issues if the name is not quoted correctly.
Replace the whitespace characters with an underscore to prevent the possible issues caused by the name splitting.
--- tools/perf/tests/builtin-test.c | 8 ++++++++ 1 file changed, 8 insertions(+)
tools/perf/tests/builtin-test.c +8 -0
@@ -283,6 +283,7 @@ static bool test_exclusive(const struct test_suite *t, int test_case)return t->test_cases[test_case].exclusive; } +static int delete_file (const char *fpath,const struct stat *sb__maybe_unused ,int typeflag,struct FTW *ftwbuf) {
@@ -331,12 +332,19 @@ static char *setup_shell_logs(const char *name) {char template[PATH_MAX ];char *temp_dir; +size_t i;if (snprintf (template,PATH_MAX ,"/tmp/perf_test_%s.XXXXXX" , name) <0 ) {pr_err ("Failed to create log dir template" );return NULL ;/* Skip the testsuite */ } +/* Replace non-alphanumeric characters with _ in the name part */ +for (i =15 ; template[i] !='.' && template[i] !='\0' ; i++) { +if (!isalnum ((unsigned char )template[i])) + template[i] ='_' ; + } + temp_dir =mkdtemp (template);if (temp_dir) {setenv ("PERFSUITE_RUN_DIR" , temp_dir,1 );
Signature · 1 line
2.51.1
PATCH v5 6/7 perf test: Remove perftool drivers
In reply to Jakub BrnakThe perf now provides all of the features required for running the perftool test cases, such as creating log directories, running setup scripts and the tests are structured by the base_ directories.
Remove the drivers as they are no longer necessary together with the condition of skipping the base_ directories and run the test cases by the default perf test structure.
--- .../tests/shell/perftool-testsuite_probe.sh | 24 ------------------- .../tests/shell/perftool-testsuite_report.sh | 23 ------------------ tools/perf/tests/tests-scripts.c | 3 --- 3 files changed, 50 deletions(-) delete mode 100755 tools/perf/tests/shell/perftool-testsuite_probe.sh delete mode 100755 tools/perf/tests/shell/perftool-testsuite_report.sh
tools/perf/tests/shell/perftool-testsuite_probe.sh deleted +0 -24
@@ -1,24 +0,0 @@ -#!/bin/bash -# perftool-testsuite_probe (exclusive) -# SPDX-License-Identifier: GPL-2.0 - -[ "$(id -u)" = 0 ] || exit 2 -test -d "$(dirname "$0")/base_probe" || exit 2 -cd "$(dirname "$0")/base_probe" || exit 2 -status=0 - -PERFSUITE_RUN_DIR=$(mktemp -d /tmp/"$(basename "$0" .sh)".XXX) -export PERFSUITE_RUN_DIR - -for testcase in setup.sh test_*; do # skip setup.sh if not present or not executable - test -x "$testcase" || continue - ./"$testcase" - (( status += $? )) -done - -if ! [ "$PERFTEST_KEEP_LOGS" = "y" ]; then - rm -rf "$PERFSUITE_RUN_DIR" -fi - -test $status -ne 0 && exit 1 -exit 0
tools/perf/tests/shell/perftool-testsuite_report.sh deleted +0 -23
@@ -1,23 +0,0 @@ -#!/bin/bash -# perftool-testsuite_report (exclusive) -# SPDX-License-Identifier: GPL-2.0 - -test -d "$(dirname "$0")/base_report" || exit 2 -cd "$(dirname "$0")/base_report" || exit 2 -status=0 - -PERFSUITE_RUN_DIR=$(mktemp -d /tmp/"$(basename "$0" .sh)".XXX) -export PERFSUITE_RUN_DIR - -for testcase in setup.sh test_*; do # skip setup.sh if not present or not executable - test -x "$testcase" || continue - ./"$testcase" - (( status += $? )) -done - -if ! [ "$PERFTEST_KEEP_LOGS" = "y" ]; then - rm -rf "$PERFSUITE_RUN_DIR" -fi - -test $status -ne 0 && exit 1 -exit 0
tools/perf/tests/tests-scripts.c +0 -3
@@ -424,9 +424,6 @@ static void append_suites_in_dir(int dir_fd,if (!is_directory_fd (dir_fd, ent))continue ; -if (strncmp (ent->d_name,"base_" ,5 ) ==0 ) -continue ;/* Skip scripts that have a separate driver. */ -/* Scan subdir for test cases*/ fd =openat (dir_fd, ent->d_name,O_PATH ); test_suite =prepare_test_suite (fd);/* Prepare a testsuite with its path */
Signature · 1 line
2.51.1
PATCH v5 7/7 perf test: Fix relative path for 'stderr-whitelist.txt'
In reply to Jakub BrnakThe test scripts for 'perf report' profiles were failing to locate the 'stderr-whitelist.txt' file.
The path was specified simply as "stderr-whitelist.txt", which relies on the current working directory when the script runs.
This patch updates the path to use the relative directory variable '$DIR_PATH' (which points to the current directory of the test script), ensuring the correct file is found regardless of the current working directory.
--- tools/perf/tests/shell/base_report/test_basic.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/tests/shell/base_report/test_basic.sh +3 -3
@@ -240,7 +240,7 @@ PERF_EXIT_CODE=$? "# Overhead Latency Command" < $LOGS_DIR/latency_default.log CHECK_EXIT_CODE=$? "$DIR_PATH/../common/check_errors_whitelisted.pl" \ - "stderr-whitelist.txt" < $LOGS_DIR/latency_default.err + "$DIR_PATH/stderr-whitelist.txt" < $LOGS_DIR/latency_default.err (( CHECK_EXIT_CODE += $? )) print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "default report for latency profile"
@@ -255,7 +255,7 @@ PERF_EXIT_CODE=$? "# Latency Overhead Command" < $LOGS_DIR/latency_latency.log CHECK_EXIT_CODE=$? "$DIR_PATH/../common/check_errors_whitelisted.pl" \ - "stderr-whitelist.txt" < $LOGS_DIR/latency_latency.err + "$DIR_PATH/stderr-whitelist.txt" < $LOGS_DIR/latency_latency.err (( CHECK_EXIT_CODE += $? )) print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "latency report for latency profile"
@@ -271,7 +271,7 @@ PERF_EXIT_CODE=$? < $LOGS_DIR/parallelism_hierarchy.log CHECK_EXIT_CODE=$? "$DIR_PATH/../common/check_errors_whitelisted.pl" \ - "stderr-whitelist.txt" < $LOGS_DIR/parallelism_hierarchy.err + "$DIR_PATH/stderr-whitelist.txt" < $LOGS_DIR/parallelism_hierarchy.err (( CHECK_EXIT_CODE += $? )) print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "parallelism histogram"
Signature · 1 line
2.51.1
Hello Ian and Namhyung,
kindly reminding this patchset. Could we get it merged soon please? Or is there still anything to address?
Thanks in advance!
Regards,
Michael
Quoted 45 lines · Jakub Brnak
Hi maintainers,
This revision of series of patches continues the effort of upstreaming a perftool-testsuite and incorporates the review feedback that was previously discussed.
A new patch (7/7) was added to fix the incorrect relative path for locating stderr-whitelist.txt in report tests.Thanks,
JakubLink to v4: https://lore.kernel.org/linux-perf-users/[email protected]/#t
Changes since v4:
Patch 1: applied review feedback, renamedshell_info->shell_test_info, minor cleanups Patch 2: renamedshell_info->shell_test_info
Patch 4: renamedshell_info->shell_test_info
Patch 7: added in v5, fix for relative path to
stderr-whitelist.txt in report testsJakub Brnak (7):
perf tests: Create a structure for shell tests perf test: Provide setup for the shell test suite
perftool-testsuite: Add empty setup forbase_probeperf test: Introduce storing logs for shell tests perf test: Format log directories for shell tests perf test: Remove perftool drivers
perf test: Fix relative path for 'stderr-whitelist.txt'tools/perf/tests/builtin-test.c | 129 +++++++- tools/perf/tests/shell/base_probe/setup.sh | 13 + .../tests/shell/base_report/test_basic.sh | 6 +- .../tests/shell/perftool-testsuite_probe.sh | 24 -- .../tests/shell/perftool-testsuite_report.sh | 23 -- tools/perf/tests/tests-scripts.c | 288 +++++++++++++++--- tools/perf/tests/tests-scripts.h | 15 + tools/perf/tests/tests.h | 8 +- 8 files changed, 398 insertions(+), 108 deletions(-) create mode 100755 tools/perf/tests/shell/base_probe/setup.sh delete mode 100755 tools/perf/tests/shell/perftool-testsuite_probe.sh delete mode 100755 tools/perf/tests/shell/perftool-testsuite_report.shSignature · 1 line
2.51.1
Arnaldo Carvalho de Melo
maintainerQuoted 6 lines · Michael Petlan
Hello Ian and Namhyung,
kindly reminding this patchset. Could we get it merged soon please? Or is there still anything to address?
Thanks in advance!
Just test applied and it went cleanly, will try to review it after lunch.
- Arnaldo
Quoted 49 lines
Regards,
MichaelQuoted 45 lines · Jakub Brnak
Hi maintainers,
This revision of series of patches continues the effort of upstreaming a perftool-testsuite and incorporates the review feedback that was previously discussed.
A new patch (7/7) was added to fix the incorrect relative path for locating stderr-whitelist.txt in report tests.Thanks,
JakubLink to v4: https://lore.kernel.org/linux-perf-users/[email protected]/#t
Changes since v4:
Patch 1: applied review feedback, renamedshell_info->shell_test_info, minor cleanups Patch 2: renamedshell_info->shell_test_info
Patch 4: renamedshell_info->shell_test_info
Patch 7: added in v5, fix for relative path to
stderr-whitelist.txt in report testsJakub Brnak (7):
perf tests: Create a structure for shell tests perf test: Provide setup for the shell test suite
perftool-testsuite: Add empty setup forbase_probeperf test: Introduce storing logs for shell tests perf test: Format log directories for shell tests perf test: Remove perftool drivers
perf test: Fix relative path for 'stderr-whitelist.txt'tools/perf/tests/builtin-test.c | 129 +++++++- tools/perf/tests/shell/base_probe/setup.sh | 13 + .../tests/shell/base_report/test_basic.sh | 6 +- .../tests/shell/perftool-testsuite_probe.sh | 24 -- .../tests/shell/perftool-testsuite_report.sh | 23 -- tools/perf/tests/tests-scripts.c | 288 +++++++++++++++--- tools/perf/tests/tests-scripts.h | 15 + tools/perf/tests/tests.h | 8 +- 8 files changed, 398 insertions(+), 108 deletions(-) create mode 100755 tools/perf/tests/shell/base_probe/setup.sh delete mode 100755 tools/perf/tests/shell/perftool-testsuite_probe.sh delete mode 100755 tools/perf/tests/shell/perftool-testsuite_report.shSignature · 1 line
2.51.1
Quoted 11 lines · Arnaldo Carvalho de Melo
Quoted 6 lines · Michael Petlan
Hello Ian and Namhyung,
kindly reminding this patchset. Could we get it merged soon please? Or is there still anything to address?
Thanks in advance!
Just test applied and it went cleanly, will try to review it after lunch.
I think patch 4 has an issue as the clean up is in the wrong place. There are also some file descriptor leaks. Other than those happy to have my:
on the series. Probably should get patch 4 fixed though.
Thanks,
Ian
Quoted 51 lines
- Arnaldo
Quoted 49 lines
Regards,
MichaelQuoted 45 lines · Jakub Brnak
Hi maintainers,
This revision of series of patches continues the effort of upstreaming a perftool-testsuite and incorporates the review feedback that was previously discussed.
A new patch (7/7) was added to fix the incorrect relative path for locating stderr-whitelist.txt in report tests.Thanks,
JakubLink to v4: https://lore.kernel.org/linux-perf-users/[email protected]/#t
Changes since v4:
Patch 1: applied review feedback, renamedshell_info->shell_test_info, minor cleanups Patch 2: renamedshell_info->shell_test_info
Patch 4: renamedshell_info->shell_test_info
Patch 7: added in v5, fix for relative path to
stderr-whitelist.txt in report testsJakub Brnak (7):
perf tests: Create a structure for shell tests perf test: Provide setup for the shell test suite
perftool-testsuite: Add empty setup forbase_probeperf test: Introduce storing logs for shell tests perf test: Format log directories for shell tests perf test: Remove perftool drivers
perf test: Fix relative path for 'stderr-whitelist.txt'tools/perf/tests/builtin-test.c | 129 +++++++- tools/perf/tests/shell/base_probe/setup.sh | 13 + .../tests/shell/base_report/test_basic.sh | 6 +- .../tests/shell/perftool-testsuite_probe.sh | 24 -- .../tests/shell/perftool-testsuite_report.sh | 23 -- tools/perf/tests/tests-scripts.c | 288 +++++++++++++++--- tools/perf/tests/tests-scripts.h | 15 + tools/perf/tests/tests.h | 8 +- 8 files changed, 398 insertions(+), 108 deletions(-) create mode 100755 tools/perf/tests/shell/base_probe/setup.sh delete mode 100755 tools/perf/tests/shell/perftool-testsuite_probe.sh delete mode 100755 tools/perf/tests/shell/perftool-testsuite_report.sh--
2.51.1
Arnaldo Carvalho de Melo
maintainerQuoted 14 lines · Ian Rogers
Quoted 11 lines · Arnaldo Carvalho de Melo
Quoted 6 lines · Michael Petlan
Hello Ian and Namhyung,
kindly reminding this patchset. Could we get it merged soon please? Or is there still anything to address?
Thanks in advance!
Just test applied and it went cleanly, will try to review it after lunch.
Quoted 7 lines
I think patch 4 has an issue as the clean up is in the wrong place. There are also some file descriptor leaks. Other than those happy to have my:
Reviewed-by Ian Rogers <[email protected]>on the series. Probably should get patch 4 fixed though.
Yeah, the first one I would fix myself, those leaks, but patch 4 needs some more work, Michael, Jakub, can you please take a look and address Ian review comments?
- Arnaldo