Check exported library symbols and cleanup
cover Check exported library symbols and cleanup
Hello,
Forgetting to add static to a global variable is a common mistake. So far we have relied on manual review to spot it. This is a waste of time for both the test author and reviewer.
Generally speaking all API functions have tst_ or safe_ prepended. It is simple to check that exported symbols match this naming. Although I expect the script I have created will break building on some distros.
The patchset also includes a bunch of fixes for some symbols. I have tried to fix stuff in the new API and ignored issues only in the old one.
I created another script to look for unused functions. However this relies on GNU Global. Also I'm not sure what to do with the results. FYI the unused commands are listed below:
ltpdev_ioctl_cmds_s testcases/kernel/fs/scsi/ltpfs/Ltpfs.h 62ltpdev_ioctl_cmds_t testcases/kernel/fs/scsi/ltpfs/Ltpfs.h 66tst_its_set_interval_from_ts include/tst_timer.h 747tst_ms_to_timeval include/tst_timer.h 43tst_numa_types include/tst_numa.h 93tst_timer_tcase lib/tst_timer_test.c 390tst_timespec_add_us include/tst_timer.h 820tst_timespec_diff_us include/tst_timer.h 941tst_timespec_from_ms include/tst_timer.h 717tst_timespec_sub_us include/tst_timer.h 847tst_timeval_diff_ms include/tst_timer.h 92tst_timeval_diff_us include/tst_timer.h 86tst_ts_abs_diff_ms include/tst_timer.h 1001
I have removed some from the list which actually seem to be an issue with the script or I have already submitted a patch to remove.
Richard Palethorpe (6):
API: Make some internal symbols static
API: Add tst_ to create_sig_proc
API: Add tst_ to file_* functions
API: add tst_ to mount_overlay
API: Add tst_ to hugepage opt vars
API: Check exported symbols
doc/test-writing-guidelines.txt | 2 +- include/old/old_safe_file_ops.h | 14 ++-- include/old/test.h | 1 - include/safe_file_ops_fn.h | 25 ++++---- include/tst_hugepage.h | 4 +- include/tst_safe_file_ops.h | 24 +++---- include/tst_sig_proc.h | 2 +- lib/Makefile | 12 ++++ lib/newlib_tests/tst_safe_fileops.c | 4 +- lib/safe_file_ops.c | 10 +-- lib/tst_assert.c | 4 +- lib/tst_clocks.c | 2 +- lib/tst_device.c | 2 +- lib/tst_fs_link_count.c | 2 +- lib/tst_fs_setup.c | 4 +- lib/tst_hugepage.c | 8 +-- lib/tst_res.c | 2 +- lib/tst_sig_proc.c | 2 +- lib/tst_status.c | 6 +- lib/tst_sys_conf.c | 2 +- lib/tst_test.c | 2 +- lib/tst_timer_test.c | 2 +- libs/libltpsigwait/sigwait.c | 18 +++--- scripts/check_export_syms.sh | 64 +++++++++++++++++++ testcases/cve/meltdown.c | 2 +- .../device-drivers/cpufreq/cpufreq_boost.c | 4 +- .../kernel/mem/hugetlb/hugemmap/hugemmap01.c | 14 ++-- .../kernel/mem/hugetlb/hugemmap/hugemmap02.c | 14 ++-- .../kernel/mem/hugetlb/hugemmap/hugemmap04.c | 14 ++-- .../mem/hugetlb/hugeshmat/hugeshmat01.c | 2 +- .../mem/hugetlb/hugeshmat/hugeshmat02.c | 2 +- .../mem/hugetlb/hugeshmat/hugeshmat03.c | 2 +- .../mem/hugetlb/hugeshmctl/hugeshmctl01.c | 2 +- .../mem/hugetlb/hugeshmctl/hugeshmctl02.c | 2 +- .../mem/hugetlb/hugeshmctl/hugeshmctl03.c | 2 +- .../mem/hugetlb/hugeshmdt/hugeshmdt01.c | 2 +- .../mem/hugetlb/hugeshmget/hugeshmget01.c | 2 +- .../mem/hugetlb/hugeshmget/hugeshmget02.c | 2 +- .../mem/hugetlb/hugeshmget/hugeshmget03.c | 4 +- .../mem/hugetlb/hugeshmget/hugeshmget05.c | 2 +- testcases/kernel/mem/ksm/ksm01.c | 4 +- testcases/kernel/mem/ksm/ksm02.c | 4 +- testcases/kernel/mem/ksm/ksm03.c | 4 +- testcases/kernel/mem/ksm/ksm04.c | 4 +- testcases/kernel/mem/ksm/ksm05.c | 2 +- testcases/kernel/mem/ksm/ksm06.c | 8 +-- testcases/kernel/mem/swapping/swapping01.c | 2 +- .../clock_nanosleep/clock_nanosleep01.c | 2 +- testcases/kernel/syscalls/fcntl/fcntl33.c | 2 +- testcases/kernel/syscalls/fork/fork13.c | 2 +- .../syscalls/migrate_pages/migrate_pages02.c | 2 +- testcases/kernel/syscalls/ppoll/ppoll01.c | 4 +- testcases/kernel/syscalls/prctl/prctl06.c | 2 +- .../kernel/syscalls/readahead/readahead02.c | 2 +- testcases/kernel/syscalls/utils/mq_timed.h | 2 +- testcases/kernel/tracing/pt_test/pt_test.c | 4 +- .../network/can/filter-tests/can_common.h | 2 +- testcases/network/packet/fanout01.c | 6 +- 58 files changed, 211 insertions(+), 137 deletions(-) create mode 100755 scripts/check_export_syms.sh
Signature · 1 line
2.31.1
RFC PATCH 1/6 API: Make some internal symbols static
These do not appear to be referenced anywhere outside the library.
--- include/old/test.h | 1 - lib/tst_clocks.c | 2 +- lib/tst_device.c | 2 +- lib/tst_fs_link_count.c | 2 +- lib/tst_fs_setup.c | 2 +- lib/tst_res.c | 2 +- lib/tst_status.c | 6 +++--- lib/tst_test.c | 2 +- lib/tst_timer_test.c | 2 +- 9 files changed, 10 insertions(+), 11 deletions(-)
include/old/test.h +0 -1
@@ -113,7 +113,6 @@ void tst_parse_opts(int argc, char *argv[], const option_t *user_optarg, void (*user_help)(void));/* lib/tst_res.c */ -const char *strttype (int ttype);void tst_resm_ (const char *file,const int lineno,int ttype,const char *arg_fmt, ...)
lib/tst_clocks.c +1 -1
@@ -14,7 +14,7 @@typedef int (*mysyscall )(clockid_t clk_id,void *ts); -int syscall_supported_by_kernel (long sysnr) +static int syscall_supported_by_kernel (long sysnr) {int ret;
lib/tst_device.c +1 -1
@@ -446,7 +446,7 @@ int tst_is_mounted_at_tmpdir(const char *path)return tst_is_mounted (mpath); } -int find_stat_file (const char *dev,char *path,size_t path_len) +static int find_stat_file (const char *dev,char *path,size_t path_len) {const char *devname =strrchr (dev,'/' ) +1 ;
lib/tst_fs_link_count.c +1 -1
@@ -32,7 +32,7 @@* XXX: we cannot filter ext4 out, because ext2/ext3/ext4 have the * same magic number */ -const long subdir_limit_whitelist[] = { +static const long subdir_limit_whitelist[] = {TST_EXT2_OLD_MAGIC ,TST_EXT234_MAGIC ,TST_MINIX_MAGIC ,TST_MINIX_MAGIC2 ,TST_MINIX2_MAGIC ,TST_MINIX2_MAGIC2 ,TST_MINIX3_MAGIC ,TST_UDF_MAGIC ,TST_SYSV2_MAGIC ,
lib/tst_fs_setup.c +1 -1
@@ -11,7 +11,7 @@#define TST_FS_SETUP_OVERLAYFS_MSG "overlayfs is not configured in this kernel"#define TST_FS_SETUP_OVERLAYFS_CONFIG "lowerdir="OVL_LOWER",upperdir="OVL_UPPER",workdir="OVL_WORK -void create_overlay_dirs (void ) +static void create_overlay_dirs (void ) {DIR *dir =opendir (OVL_LOWER );if (dir ==NULL ) {
lib/tst_res.c +1 -1
@@ -139,7 +139,7 @@ struct pair {return pair_arr[idx].name; \ }while (0 ) -const char *strttype(int ttype) +static const char *strttype(int ttype) {static const struct pair ttype_pairs[] = {PAIR (TPASS )
lib/tst_status.c +3 -3
@@ -11,14 +11,14 @@static char buf[32 ]; -const char *exited (int status) +static const char *exited (int status) {snprintf (buf,sizeof (buf),"exited with %i" ,WEXITSTATUS (status));return buf; } -const char *signaled (int status) +static const char *signaled (int status) {snprintf (buf,sizeof (buf),"killed by %s" ,tst_strsig (WTERMSIG (status)));
@@ -26,7 +26,7 @@ const char *signaled(int status)return buf; } -const char *invalid (int status) +static const char *invalid (int status) {snprintf (buf,sizeof (buf),"invalid status 0x%x" , status);
lib/tst_test.c +1 -1
@@ -747,7 +747,7 @@ static void do_exit(int ret)exit (ret); } -void check_kver (void ) +static void check_kver (void ) {int v1, v2, v3;
lib/tst_timer_test.c +1 -1
@@ -251,7 +251,7 @@ static void write_to_file(void)* - then we compute truncated mean and compare that with the requested sleep * time increased by a threshold */ -void do_timer_test (long long usec,unsigned int nsamples) +static void do_timer_test (long long usec,unsigned int nsamples) {long long trunc_mean, median;unsigned int discard =compute_discard (nsamples);
Signature · 1 line
2.31.1
RFC PATCH 1/6 API: Make some internal symbols static
Hi Richie,
include/old/test.h void tst_parse_opts(int argc, char *argv[], const option_t *user_optarg, · line 116
Quoted 11 lines
These do not appear to be referenced anywhere outside the library.
include/old/test.h +0
-1@@ -113,7 +113,6 @@ void tst_parse_opts(int argc, char *argv[], const option_t *user_optarg, void (*user_help)(void));/* lib/tst_res.c */ -const char *strttype (int ttype);
I would not touch legacy API, but this looks to be safe.
Kind regards,
Petr
RFC PATCH 2/6 API: Add tst_ to create_sig_proc
In reply to Richard Palethorpe--- include/tst_sig_proc.h | 2 +- lib/tst_sig_proc.c | 2 +- libs/libltpsigwait/sigwait.c | 18 +++++++++--------- .../clock_nanosleep/clock_nanosleep01.c | 2 +- testcases/kernel/syscalls/ppoll/ppoll01.c | 4 ++-- testcases/kernel/syscalls/utils/mq_timed.h | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-)
include/tst_sig_proc.h +1 -1
@@ -7,6 +7,6 @@#include <sys/types.h> -pid_t create_sig_proc (int sig,int count,unsigned int usec); +pid_t tst_create_sig_proc (int sig,int count,unsigned int usec);#endif /* TST_SIG_PROC_H__ */
lib/tst_sig_proc.c +1 -1
@@ -11,7 +11,7 @@#define TST_NO_DEFAULT_MAIN #include "tst_test.h" -pid_t create_sig_proc (int sig,int count,unsigned int usec) +pid_t tst_create_sig_proc (int sig,int count,unsigned int usec) {pid_t pid, cpid;
libs/libltpsigwait/sigwait.c +9 -9
@@ -19,7 +19,7 @@ void test_empty_set(swi_func sigwaitinfo, int signo,SAFE_SIGEMPTYSET (&sigs);/* Run a child that will wake us up */ - child =create_sig_proc (signo,INT_MAX ,100000 ); + child =tst_create_sig_proc (signo,INT_MAX ,100000 );TEST (sigwaitinfo (&sigs, &si,NULL ));if (TST_RET ==-1 ) {
@@ -49,7 +49,7 @@ void test_timeout(swi_func sigwaitinfo, int signo, enum tst_ts_type type)SAFE_SIGEMPTYSET (&sigs);/* Run a child that will wake us up */ - child =create_sig_proc (signo,INT_MAX ,100000 ); + child =tst_create_sig_proc (signo,INT_MAX ,100000 );TEST (sigwaitinfo (&sigs, &si,tst_ts_get (&ts)));if (TST_RET ==-1 ) {
@@ -79,7 +79,7 @@ void test_unmasked_matching(swi_func sigwaitinfo, int signo,SAFE_SIGADDSET (&sigs, signo);/* Run a child that will wake us up */ - child =create_sig_proc (signo,INT_MAX ,100000 ); + child =tst_create_sig_proc (signo,INT_MAX ,100000 );TEST (sigwaitinfo (&sigs, &si,NULL ));if (TST_RET == signo) {
@@ -106,7 +106,7 @@ void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo,SAFE_SIGADDSET (&sigs, signo);/* Run a child that will wake us up */ - child =create_sig_proc (signo,INT_MAX ,100000 ); + child =tst_create_sig_proc (signo,INT_MAX ,100000 );TEST (sigwaitinfo (&sigs,NULL ,NULL ));if (TST_RET == signo)
@@ -139,7 +139,7 @@ void test_masked_matching(swi_func sigwaitinfo, int signo,SAFE_SIGDELSET (&sigs,SIGCHLD );/* Run a child that will wake us up */ - child =create_sig_proc (signo,1 ,0 ); + child =tst_create_sig_proc (signo,1 ,0 );TEST (sigwaitinfo (&sigs, &si,NULL ));if (TST_RET == signo) {
@@ -191,8 +191,8 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo,SAFE_SIGDELSET (&sigs,SIGCHLD );/* Run a child that will wake us up */ - child[0 ] =create_sig_proc (signo,1 ,0 ); - child[1 ] =create_sig_proc (signo +1 ,1 ,0 ); + child[0 ] =tst_create_sig_proc (signo,1 ,0 ); + child[1 ] =tst_create_sig_proc (signo +1 ,1 ,0 );/* Ensure that the signals have been sent */ SAFE_WAITPID (child[0 ], &status,0 );
@@ -252,7 +252,7 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo,SAFE_SIGDELSET (&sigs,SIGCHLD );/* Run a child that will wake us up */ - child =create_sig_proc (signo,1 ,0 ); + child =tst_create_sig_proc (signo,1 ,0 );TEST (sigwaitinfo (&sigs,NULL ,NULL ));if (TST_RET == signo)
@@ -294,7 +294,7 @@ void test_bad_address(swi_func sigwaitinfo, int signo,SAFE_SIGDELSET (&sigs,SIGCHLD );/* Run a child that will wake us up */ - child =create_sig_proc (signo,1 ,0 ); + child =tst_create_sig_proc (signo,1 ,0 );TEST (sigwaitinfo (&sigs, (void *)1 ,NULL ));if (TST_RET ==-1 ) {
testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c +1 -1
@@ -139,7 +139,7 @@ static void do_test(unsigned int i)tst_res (TINFO ,"case %s" , tc->desc);if (tc->ttype ==SEND_SIGINT || tc->ttype ==BAD_TS_ADDR_REM ) - pid =create_sig_proc (SIGINT ,40 ,500000 ); + pid =tst_create_sig_proc (SIGINT ,40 ,500000 );tst_ts_set_sec (rq, tc->tv_sec);tst_ts_set_nsec (rq, tc->tv_nsec);
testcases/kernel/syscalls/ppoll/ppoll01.c +2 -2
@@ -251,8 +251,8 @@ static void do_test(unsigned int i)tst_brk (TBROK ,"sigprocmask" ); }if (tc->sigint_count >0 ) { - pid =create_sig_proc (SIGINT , tc->sigint_count, - tc->sigint_delay); + pid =tst_create_sig_proc (SIGINT , tc->sigint_count, + tc->sigint_delay); }/* test */
testcases/kernel/syscalls/utils/mq_timed.h +1 -1
@@ -45,7 +45,7 @@ static pid_t set_sig(struct tst_ts *ts,gettime (CLOCK_REALTIME ,tst_ts_get (ts)); *ts =tst_ts_add_us (*ts,3000000 ); -return create_sig_proc (SIGINT ,40 ,50000 ); +return tst_create_sig_proc (SIGINT ,40 ,50000 ); } static void set_timeout(struct tst_ts *ts,
Signature · 1 line
2.31.1
RFC PATCH 2/6 API: Add tst_ to create_sig_proc
Quoted 2 lines · Richard Palethorpe via ltp
Signed-off-by Richard Palethorpe <[email protected]>
--
Regards,
Li Wang
RFC PATCH 2/6 API: Add tst_ to create_sig_proc
In reply to Richard PalethorpeHi Richie,
also this one is obviously ok, thanks!
Kind regards,
Petr
RFC PATCH 3/6 API: Add tst_ to file_* functions
In reply to Richard PalethorpeUsually LTP library functions are prepended with tst_ if not with safe_.
--- doc/test-writing-guidelines.txt | 2 +- include/old/old_safe_file_ops.h | 14 ++++++------ include/safe_file_ops_fn.h | 22 +++++++++---------- include/tst_safe_file_ops.h | 20 ++++++++--------- lib/newlib_tests/tst_safe_fileops.c | 4 ++-- lib/safe_file_ops.c | 10 ++++----- lib/tst_assert.c | 4 ++-- lib/tst_sys_conf.c | 2 +- testcases/cve/meltdown.c | 2 +- .../device-drivers/cpufreq/cpufreq_boost.c | 4 ++-- .../mem/hugetlb/hugeshmget/hugeshmget03.c | 2 +- testcases/kernel/mem/ksm/ksm01.c | 4 ++-- testcases/kernel/mem/ksm/ksm02.c | 4 ++-- testcases/kernel/mem/ksm/ksm03.c | 4 ++-- testcases/kernel/mem/ksm/ksm04.c | 4 ++-- testcases/kernel/mem/ksm/ksm05.c | 2 +- testcases/kernel/mem/ksm/ksm06.c | 8 +++---- testcases/kernel/mem/swapping/swapping01.c | 2 +- testcases/kernel/syscalls/fcntl/fcntl33.c | 2 +- testcases/kernel/syscalls/fork/fork13.c | 2 +- .../syscalls/migrate_pages/migrate_pages02.c | 2 +- testcases/kernel/syscalls/prctl/prctl06.c | 2 +- .../kernel/syscalls/readahead/readahead02.c | 2 +- testcases/kernel/tracing/pt_test/pt_test.c | 4 ++-- .../network/can/filter-tests/can_common.h | 2 +- testcases/network/packet/fanout01.c | 6 ++--- 26 files changed, 68 insertions(+), 68 deletions(-)
doc/test-writing-guidelines.txt +1 -1
@@ -1715,7 +1715,7 @@ static const char *save_restore[] = { static void setup(void) { - FILE_PRINTF("/proc/sys/kernel/core_pattern", "/mypath"); + TST_FILE_PRINTF("/proc/sys/kernel/core_pattern", "/mypath"); } static struct tst_test test = {
include/old/old_safe_file_ops.h +7 -7
@@ -30,24 +30,24 @@#include "safe_file_ops_fn.h" -#define FILE_SCANF (path, fmt, ...) \ - file_scanf(__FILE__, __LINE__, \ - (path), (fmt), ## __VA_ARGS__) +#define TST_FILE_SCANF (path, fmt, ...) \ + tst_file_scanf(__FILE__, __LINE__, \ + (path), (fmt), ## __VA_ARGS__)#define SAFE_FILE_SCANF (cleanup_fn, path, fmt, ...) \ safe_file_scanf(__FILE__, __LINE__, (cleanup_fn), \ (path), (fmt), ## __VA_ARGS__)#define FILE_LINES_SCANF (cleanup_fn, path, fmt, ...) \ - file_lines_scanf(__FILE__, __LINE__, (cleanup_fn), 0, \ + tst_file_lines_scanf(__FILE__, __LINE__, (cleanup_fn), 0, \ (path), (fmt), ## __VA_ARGS__)#define SAFE_FILE_LINES_SCANF (cleanup_fn, path, fmt, ...) \ - file_lines_scanf(__FILE__, __LINE__, (cleanup_fn), 1, \ + tst_file_lines_scanf(__FILE__, __LINE__, (cleanup_fn), 1, \ (path), (fmt), ## __VA_ARGS__) -#define FILE_PRINTF (path, fmt, ...) \ - file_printf(__FILE__, __LINE__, \ +#define TST_FILE_PRINTF (path, fmt, ...) \ + tst_file_printf(__FILE__, __LINE__, \ (path), (fmt), ## __VA_ARGS__)#define SAFE_FILE_PRINTF (cleanup_fn, path, fmt, ...) \
include/safe_file_ops_fn.h +11 -11
@@ -36,31 +36,31 @@ int tst_count_scanf_conversions(const char *fmt);/* * All-in-one function to scanf value(s) from a file. */ -int file_scanf (const char *file,const int lineno, -const char *path,const char *fmt, ...) - __attribute__ ((format (scanf,4 ,5 ))); +int tst_file_scanf (const char *file,const int lineno, +const char *path,const char *fmt, ...) + __attribute__ ((format (scanf,4 ,5 )));void safe_file_scanf (const char *file,const int lineno,void (*cleanup_fn)(void ),const char *path,const char *fmt, ...) __attribute__ ((format (scanf,5 ,6 ))); -int file_lines_scanf (const char *file,const int lineno, -void (*cleanup_fn)(void ),int strict, -const char *path,const char *fmt, ...) - __attribute__ ((format (scanf,6 ,7 ))); +int tst_file_lines_scanf (const char *file,const int lineno, +void (*cleanup_fn)(void ),int strict, +const char *path,const char *fmt, ...) + __attribute__ ((format (scanf,6 ,7 )));/* * All-in-one function that lets you printf directly into a file. */ -int file_printf (const char *file,const int lineno, -const char *path,const char *fmt, ...) - __attribute__ ((format (printf,4 ,5 ))); +int tst_file_printf (const char *file,const int lineno, +const char *path,const char *fmt, ...) + __attribute__ ((format (printf,4 ,5 )));void safe_file_printf (const char *file,const int lineno,void (*cleanup_fn)(void ),const char *path,const char *fmt, ...) - __attribute__ ((format (printf,5 ,6 ))); + __attribute__ ((format (printf,5 ,6 )));/* * Safe function to copy files, no more system("cp ...") please.
include/tst_safe_file_ops.h +10 -10
@@ -7,20 +7,20 @@#include "safe_file_ops_fn.h" -#define FILE_SCANF (path, fmt, ...) \ - file_scanf(__FILE__, __LINE__, (path), (fmt), ## __VA_ARGS__) +#define TST_FILE_SCANF (path, fmt, ...) \ + tst_file_scanf(__FILE__, __LINE__, (path), (fmt), ## __VA_ARGS__)#define SAFE_FILE_SCANF (path, fmt, ...) \ safe_file_scanf(__FILE__, __LINE__, NULL, \ (path), (fmt), ## __VA_ARGS__) -#define FILE_LINES_SCANF (path, fmt, ...) \ - file_lines_scanf(__FILE__, __LINE__, NULL, 0,\ - (path), (fmt), ## __VA_ARGS__) +#define TST_FILE_LINES_SCANF (path, fmt, ...) \ + tst_file_lines_scanf(__FILE__, __LINE__, NULL, 0,\ + (path), (fmt), ## __VA_ARGS__)#define SAFE_FILE_LINES_SCANF (path, fmt, ...) \ - file_lines_scanf(__FILE__, __LINE__, NULL, 1,\ - (path), (fmt), ## __VA_ARGS__) + tst_file_lines_scanf(__FILE__, __LINE__, NULL, 1,\ + (path), (fmt), ## __VA_ARGS__)#define SAFE_READ_MEMINFO (item) \ ({long tst_rval; \
@@ -36,9 +36,9 @@ &tst_rval_); \ tst_rval_;}) -#define FILE_PRINTF (path, fmt, ...) \ - file_printf(__FILE__, __LINE__, \ - (path), (fmt), ## __VA_ARGS__) +#define TST_FILE_PRINTF (path, fmt, ...) \ + tst_file_printf(__FILE__, __LINE__, \ + (path), (fmt), ## __VA_ARGS__)#define SAFE_FILE_PRINTF (path, fmt, ...) \ safe_file_printf(__FILE__, __LINE__, NULL, \
lib/newlib_tests/tst_safe_fileops.c +2 -2
@@ -13,11 +13,11 @@ static void do_test(void)long dummy;SAFE_FILE_LINES_SCANF ("/proc/meminfo" ,"MemFree: %ld" , &free); -if (FILE_LINES_SCANF ("/proc/stat" ,"processes %ld" , &nproc)) +if (TST_FILE_LINES_SCANF ("/proc/stat" ,"processes %ld" , &nproc))tst_brk (TBROK ,"Could not parse processes" );tst_res (TPASS ,"Free: %ld, nproc: %ld" , free, nproc); -if (FILE_LINES_SCANF ("/proc/stat" ,"non-existent %ld" , &dummy)) +if (TST_FILE_LINES_SCANF ("/proc/stat" ,"non-existent %ld" , &dummy))tst_res (TPASS ,"non-existent not found" );SAFE_FILE_LINES_SCANF ("/proc/stat" ,"non-existent %ld" , &dummy); }
lib/safe_file_ops.c +5 -5
@@ -66,7 +66,7 @@ int tst_count_scanf_conversions(const char *fmt)return cnt; } -int file_scanf (const char *file,const int lineno, +int tst_file_scanf (const char *file,const int lineno,const char *path,const char *fmt, ...) {va_list va;
@@ -165,9 +165,9 @@ void safe_file_scanf(const char *file, const int lineno,* to scanf format 'fmt'. If all fields could be parsed, stop and * return 0, otherwise continue or return 1 if EOF is reached. */ -int file_lines_scanf (const char *file,const int lineno, -void (*cleanup_fn)(void ),int strict, -const char *path,const char *fmt, ...) +int tst_file_lines_scanf (const char *file,const int lineno, +void (*cleanup_fn)(void ),int strict, +const char *path,const char *fmt, ...) {FILE *fp;int ret =0 ;
@@ -209,7 +209,7 @@ int file_lines_scanf(const char *file, const int lineno,return !(ret == arg_count); } -int file_printf (const char *file,const int lineno, +int tst_file_printf (const char *file,const int lineno,const char *path,const char *fmt, ...) {va_list va;
lib/tst_assert.c +2 -2
@@ -43,7 +43,7 @@ void tst_assert_file_int(const char *file, const int lineno, const char *path, cchar fmt[1024 ];snprintf (fmt,sizeof (fmt),"%s%%d" , prefix); -file_lines_scanf (file, lineno,NULL ,1 , path, fmt, &sys_val); +tst_file_lines_scanf (file, lineno,NULL ,1 , path, fmt, &sys_val);if (val == sys_val) {tst_res_ (file, lineno,TPASS ,"%s %s = %d" , path, prefix, sys_val);
@@ -72,7 +72,7 @@ void tst_assert_file_str(const char *file, const int lineno, const char *path, cchar fmt[2048 ];snprintf (fmt,sizeof (fmt),"%s: %%1024s" , prefix); -file_lines_scanf (file, lineno,NULL ,1 , path, fmt, sys_val); +tst_file_lines_scanf (file, lineno,NULL ,1 , path, fmt, sys_val);if (!strcmp (val, sys_val)) {tst_res_ (file, lineno,TPASS ,"%s %s = '%s'" , path, prefix, sys_val);
lib/tst_sys_conf.c +1 -1
@@ -99,7 +99,7 @@ void tst_sys_conf_restore(int verbose)tst_res (TINFO ,"Restoring conf.: %s -> %s\n" , i->path, i->value); } -FILE_PRINTF (i->path,"%s" , i->value); +TST_FILE_PRINTF (i->path,"%s" , i->value); } }
testcases/cve/meltdown.c +1 -1
@@ -261,7 +261,7 @@ find_symbol_in_file(const char *filename, const char *symname)sprintf (fmt,"%%lx %%c %s%%c" , symname); - ret =FILE_LINES_SCANF (filename, fmt, &addr, &type, &read); + ret =TST_FILE_LINES_SCANF (filename, fmt, &addr, &type, &read);if (ret)return 0 ;
testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c +2 -2
@@ -78,10 +78,10 @@ static void check_set_turbo(char *file, char *off)static void cleanup (void ) { -FILE_PRINTF (cdrv[id].file,"%d" , boost_value); +TST_FILE_PRINTF (cdrv[id].file,"%d" , boost_value);if (governor[0 ] !='\0' ) -FILE_PRINTF (governor,"%s" , governor_name); +TST_FILE_PRINTF (governor,"%s" , governor_name); }static void setup (void )
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c +1 -1
@@ -84,7 +84,7 @@ static void cleanup(void)rm_shm (shm_id_arr[i]);if (orig_shmmni !=-1 ) -FILE_PRINTF (PATH_SHMMNI ,"%ld" , orig_shmmni); +TST_FILE_PRINTF (PATH_SHMMNI ,"%ld" , orig_shmmni); }static struct tst_test test = {
testcases/kernel/mem/ksm/ksm01.c +2 -2
@@ -88,8 +88,8 @@ static void setup(void)static void cleanup (void ) {if (access (PATH_KSM "merge_across_nodes" ,F_OK ) ==0 ) -FILE_PRINTF (PATH_KSM "merge_across_nodes" , -"%d" , merge_across_nodes); +TST_FILE_PRINTF (PATH_KSM "merge_across_nodes" , +"%d" , merge_across_nodes); }static struct tst_test test = {
testcases/kernel/mem/ksm/ksm02.c +2 -2
@@ -88,8 +88,8 @@ static void verify_ksm(void)static void cleanup (void ) {if (access (PATH_KSM "merge_across_nodes" ,F_OK ) ==0 ) -FILE_PRINTF (PATH_KSM "merge_across_nodes" , -"%d" , merge_across_nodes); +TST_FILE_PRINTF (PATH_KSM "merge_across_nodes" , +"%d" , merge_across_nodes);tst_cgroup_cleanup (); }
testcases/kernel/mem/ksm/ksm03.c +2 -2
@@ -88,8 +88,8 @@ static void setup(void)static void cleanup (void ) {if (access (PATH_KSM "merge_across_nodes" ,F_OK ) ==0 ) -FILE_PRINTF (PATH_KSM "merge_across_nodes" , -"%d" , merge_across_nodes); +TST_FILE_PRINTF (PATH_KSM "merge_across_nodes" , +"%d" , merge_across_nodes);tst_cgroup_cleanup (); }
testcases/kernel/mem/ksm/ksm04.c +2 -2
@@ -87,8 +87,8 @@ static void verify_ksm(void)static void cleanup (void ) {if (access (PATH_KSM "merge_across_nodes" ,F_OK ) ==0 ) -FILE_PRINTF (PATH_KSM "merge_across_nodes" , -"%d" , merge_across_nodes); +TST_FILE_PRINTF (PATH_KSM "merge_across_nodes" , +"%d" , merge_across_nodes);tst_cgroup_cleanup (); }
testcases/kernel/mem/ksm/ksm05.c +1 -1
@@ -99,7 +99,7 @@ static void cleanup(void) {/* restore /sys/kernel/mm/ksm/run value */ if (ksm_run_orig >0 ) -FILE_PRINTF (PATH_KSM "run" ,"%d" , ksm_run_orig); +TST_FILE_PRINTF (PATH_KSM "run" ,"%d" , ksm_run_orig); }static struct tst_test test = {
testcases/kernel/mem/ksm/ksm06.c +4 -4
@@ -75,15 +75,15 @@ static void setup(void)static void cleanup (void ) {if (merge_across_nodes !=-1 ) { -FILE_PRINTF (PATH_KSM "merge_across_nodes" , -"%d" , merge_across_nodes); +TST_FILE_PRINTF (PATH_KSM "merge_across_nodes" , +"%d" , merge_across_nodes); }if (sleep_millisecs !=-1 ) -FILE_PRINTF (PATH_KSM "sleep_millisecs" ,"%d" , sleep_millisecs); +TST_FILE_PRINTF (PATH_KSM "sleep_millisecs" ,"%d" , sleep_millisecs);if (run !=-1 ) -FILE_PRINTF (PATH_KSM "run" ,"%d" , run); +TST_FILE_PRINTF (PATH_KSM "run" ,"%d" , run); }static struct tst_test test = {
testcases/kernel/mem/swapping/swapping01.c +1 -1
@@ -83,7 +83,7 @@ static void test_swapping(void)static void init_meminfo (void ) { swap_free_init =SAFE_READ_MEMINFO ("SwapFree:" ); -if (FILE_LINES_SCANF ("/proc/meminfo" ,"MemAvailable: %ld" , +if (TST_FILE_LINES_SCANF ("/proc/meminfo" ,"MemAvailable: %ld" , &mem_available_init)) { mem_available_init =SAFE_READ_MEMINFO ("MemFree:" ) +SAFE_READ_MEMINFO ("Cached:" );
testcases/kernel/syscalls/fcntl/fcntl33.c +1 -1
@@ -209,7 +209,7 @@ static void cleanup(void)SAFE_CLOSE (fd);/* Restore the lease-break-time. */ -FILE_PRINTF (PATH_LS_BRK_T ,"%d" , ls_brk_t); +TST_FILE_PRINTF (PATH_LS_BRK_T ,"%d" , ls_brk_t); }static struct tst_test test = {
testcases/kernel/syscalls/fork/fork13.c +1 -1
@@ -143,7 +143,7 @@ static void setup(void)static void cleanup (void ) {/* Restore pid_max value. */ -FILE_PRINTF (PID_MAX_PATH ,"%lu" , pid_max); +TST_FILE_PRINTF (PID_MAX_PATH ,"%lu" , pid_max); }/* The distance mod PIDMAX between two pids, where the first pid is
testcases/kernel/syscalls/migrate_pages/migrate_pages02.c +1 -1
@@ -276,7 +276,7 @@ static void setup(void)else if (tst_kvercmp (2 ,6 ,18 ) <0 )tst_brk (TCONF ,"2.6.18 or greater kernel required" ); -FILE_PRINTF ("/proc/sys/kernel/numa_balancing" ,"0" ); +TST_FILE_PRINTF ("/proc/sys/kernel/numa_balancing" ,"0" );/* * find 2 nodes, which can hold NODE_MIN_FREEMEM bytes * The reason is that:
testcases/kernel/syscalls/prctl/prctl06.c +1 -1
@@ -87,7 +87,7 @@ static void setup(void)SAFE_CHOWN (BIN_PATH ,0 ,0 );SAFE_CHMOD (BIN_PATH ,SUID_MODE ); -if (FILE_LINES_SCANF (PROC_STATUS ,"NoNewPrivs:%d" , &field)) { +if (TST_FILE_LINES_SCANF (PROC_STATUS ,"NoNewPrivs:%d" , &field)) {tst_res (TCONF ,"%s doesn't support NoNewPrivs field" ,PROC_STATUS ); proc_flag =0 ; proc_sup ="No" ;
testcases/kernel/syscalls/readahead/readahead02.c +1 -1
@@ -351,7 +351,7 @@ static void setup_readahead_length(void)/* raise bdi limit as much as kernel allows */ ra_new_limit = testfile_size /1024 ;while (ra_new_limit > pagesize /1024 ) { -FILE_PRINTF (sys_bdi_ra_path,"%d" , ra_new_limit); +TST_FILE_PRINTF (sys_bdi_ra_path,"%d" , ra_new_limit);SAFE_FILE_SCANF (sys_bdi_ra_path,"%d" , &ra_limit);if (ra_limit == ra_new_limit) {
testcases/kernel/tracing/pt_test/pt_test.c +2 -2
@@ -128,11 +128,11 @@ static int is_affected_by_erratum_BDM106(void) {int family =-1 , model =-1 ; -if (FILE_LINES_SCANF ("/proc/cpuinfo" ,"cpu family%*s%d" , &family) +if (TST_FILE_LINES_SCANF ("/proc/cpuinfo" ,"cpu family%*s%d" , &family) || family !=6 )return 0 ; -if (!FILE_LINES_SCANF ("/proc/cpuinfo" ,"model%*s%d" , &model)) { +if (!TST_FILE_LINES_SCANF ("/proc/cpuinfo" ,"model%*s%d" , &model)) {tst_res (TINFO ,"Intel FAM6 model %d" , model);switch (model) {
testcases/network/can/filter-tests/can_common.h +1 -1
@@ -53,7 +53,7 @@ static void can_setup_vcan(void) check_echo:SAFE_ASPRINTF (&path,"/sys/class/net/%s/flags" , can_dev_name); -if (FILE_SCANF (path,"%x" , &flags) || !(flags &IFF_ECHO )) { +if (TST_FILE_SCANF (path,"%x" , &flags) || !(flags &IFF_ECHO )) {tst_res (TWARN ,"Could not determine if ECHO is set on %s. This may effect code coverage." , can_dev_name);
testcases/network/packet/fanout01.c +3 -3
@@ -41,9 +41,9 @@ void setup(void)if (TST_RET )tst_brk (TBROK |TTERRNO ,"Can't create new net namespace" ); -FILE_PRINTF ("/proc/self/setgroups" ,"deny" ); -FILE_PRINTF ("/proc/self/uid_map" ,"0 %d 1\n" , real_uid); -FILE_PRINTF ("/proc/self/gid_map" ,"0 %d 1\n" , real_gid); +TST_FILE_PRINTF ("/proc/self/setgroups" ,"deny" ); +TST_FILE_PRINTF ("/proc/self/uid_map" ,"0 %d 1\n" , real_uid); +TST_FILE_PRINTF ("/proc/self/gid_map" ,"0 %d 1\n" , real_gid);tst_fzsync_pair_init (&pair); }
Signature · 1 line
2.31.1
RFC PATCH 3/6 API: Add tst_ to file_* functions
Quoted 3 lines · Richard Palethorpe via ltp
Usually LTP library functions are prepended with
tst_if not withsafe_.
I'm not very sure if FILE_PRINTF should be added with TST_ prefix, but it seems no harm to do that.
So I just hold a neutral view on this patch:).
Signature · 2 lines
Regards, Li Wang
RFC PATCH 3/6 API: Add tst_ to file_* functions
In reply to Richard PalethorpeHi Richie,
Quoted 2 lines
Usually LTP library functions are prepended with
tst_if not withsafe_.
LGTM.
Kind regards,
Petr
RFC PATCH 4/6 API: add tst_ to mount_overlay
In reply to Richard Palethorpe--- include/safe_file_ops_fn.h | 3 +-- include/tst_safe_file_ops.h | 4 ++-- lib/tst_fs_setup.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-)
include/safe_file_ops_fn.h +1 -2
@@ -87,7 +87,6 @@ int safe_touch(const char *file, const int lineno, mode_t mode, const struct timespec times[2]);/* helper functions to setup overlayfs mountpoint */ -void create_overlay_dirs (void ); -int mount_overlay (const char *file,const int lineno,int skip); +int tst_mount_overlay (const char *file,const int lineno,int skip);#endif /* SAFE_FILE_OPS_FN */
include/tst_safe_file_ops.h +2 -2
@@ -52,9 +52,9 @@ (pathname), (mode), (times))#define SAFE_MOUNT_OVERLAY () \ - ((void) mount_overlay(__FILE__, __LINE__, 1)) + ((void) tst_mount_overlay(__FILE__, __LINE__, 1))#define TST_MOUNT_OVERLAY () \ - (mount_overlay(__FILE__, __LINE__, 0) == 0) + (tst_mount_overlay(__FILE__, __LINE__, 0) == 0)#endif /* TST_SAFE_FILE_OPS */
lib/tst_fs_setup.c +1 -1
@@ -24,7 +24,7 @@ static void create_overlay_dirs(void)closedir (dir); } -int mount_overlay (const char *file,const int lineno,int skip) +int tst_mount_overlay (const char *file,const int lineno,int skip) {int ret;
Signature · 1 line
2.31.1
RFC PATCH 4/6 API: add tst_ to mount_overlay
Quoted 2 lines · Richard Palethorpe via ltp
Signed-off-by Richard Palethorpe <[email protected]>
Signature · 2 lines
Regards, Li Wang
RFC PATCH 4/6 API: add tst_ to mount_overlay
In reply to Richard PalethorpeRFC PATCH 5/6 API: Add tst_ to hugepage opt vars
In reply to Richard Palethorpe--- include/tst_hugepage.h | 4 ++-- lib/tst_hugepage.c | 8 ++++---- testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c | 14 +++++++------- testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c | 14 +++++++------- testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c | 14 +++++++------- .../kernel/mem/hugetlb/hugeshmat/hugeshmat01.c | 2 +- .../kernel/mem/hugetlb/hugeshmat/hugeshmat02.c | 2 +- .../kernel/mem/hugetlb/hugeshmat/hugeshmat03.c | 2 +- .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c | 2 +- .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c | 2 +- .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c | 2 +- .../kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c | 2 +- .../kernel/mem/hugetlb/hugeshmget/hugeshmget01.c | 2 +- .../kernel/mem/hugetlb/hugeshmget/hugeshmget02.c | 2 +- .../kernel/mem/hugetlb/hugeshmget/hugeshmget03.c | 2 +- .../kernel/mem/hugetlb/hugeshmget/hugeshmget05.c | 2 +- 16 files changed, 38 insertions(+), 38 deletions(-)
include/tst_hugepage.h +2 -2
@@ -9,8 +9,8 @@#define PATH_HUGEPAGES "/sys/kernel/mm/hugepages/"#define PATH_NR_HPAGES "/proc/sys/vm/nr_hugepages" -extern char *nr_opt;/* -s num Set the number of the been allocated hugepages */ -extern char *Hopt;/* -H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs */ +extern char *tst_hugepage_nr_opt;/* -s num Set the number of the been allocated hugepages */ +extern char *tst_hugepage_Hopt;/* -H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs */ /* * Get the default hugepage size. Returns 0 if hugepages are not supported.
lib/tst_hugepage.c +4 -4
@@ -9,8 +9,8 @@#include "tst_hugepage.h" unsigned long tst_hugepages; -char *nr_opt; -char *Hopt; +char *tst_hugepage_nr_opt; +char *tst_hugepage_Hopt;size_t tst_get_hugepage_size (void ) {
@@ -29,8 +29,8 @@ unsigned long tst_request_hugepages(unsigned long hpages) goto out; } -if (nr_opt) - tst_hugepages =SAFE_STRTOL (nr_opt,1 ,LONG_MAX ); +if (tst_hugepage_nr_opt) + tst_hugepages =SAFE_STRTOL (tst_hugepage_nr_opt,1 ,LONG_MAX );else tst_hugepages = hpages;
testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c +7 -7
@@ -74,25 +74,25 @@ void setup(void)if (tst_hugepages ==0 )tst_brk (TCONF ,"Not enough hugepages for testing." ); -if (!Hopt) - Hopt =tst_get_tmpdir (); -SAFE_MOUNT ("none" , Hopt,"hugetlbfs" ,0 ,NULL ); +if (!tst_hugepage_Hopt) + tst_hugepage_Hopt =tst_get_tmpdir (); +SAFE_MOUNT ("none" , tst_hugepage_Hopt,"hugetlbfs" ,0 ,NULL ); -snprintf (TEMPFILE ,sizeof (TEMPFILE ),"%s/mmapfile%d" , Hopt,getpid ()); +snprintf (TEMPFILE ,sizeof (TEMPFILE ),"%s/mmapfile%d" , tst_hugepage_Hopt,getpid ()); }void cleanup (void ) {unlink (TEMPFILE ); -umount (Hopt); +umount (tst_hugepage_Hopt); }static struct tst_test test = { .needs_root =1 , .needs_tmpdir =1 , .options = (struct tst_option []) { - {"H:" , &Hopt,"-H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs" }, - {"s:" , &nr_opt,"-s num Set the number of the been allocated hugepages" }, + {"H:" , &tst_hugepage_Hopt,"-H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs" }, + {"s:" , &tst_hugepage_nr_opt,"-s num Set the number of the been allocated hugepages" }, {} }, .setup = setup,
testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c +7 -7
@@ -121,25 +121,25 @@ static void setup(void)if (tst_hugepages ==0 )tst_brk (TCONF ,"Not enough hugepages for testing." ); -if (!Hopt) - Hopt =tst_get_tmpdir (); -SAFE_MOUNT ("none" , Hopt,"hugetlbfs" ,0 ,NULL ); +if (!tst_hugepage_Hopt) + tst_hugepage_Hopt =tst_get_tmpdir (); +SAFE_MOUNT ("none" , tst_hugepage_Hopt,"hugetlbfs" ,0 ,NULL ); -snprintf (TEMPFILE ,sizeof (TEMPFILE ),"%s/mmapfile%d" , Hopt,getpid ()); +snprintf (TEMPFILE ,sizeof (TEMPFILE ),"%s/mmapfile%d" , tst_hugepage_Hopt,getpid ()); }static void cleanup (void ) {unlink (TEMPFILE ); -umount (Hopt); +umount (tst_hugepage_Hopt); }static struct tst_test test = { .needs_root =1 , .needs_tmpdir =1 , .options = (struct tst_option []) { - {"H:" , &Hopt,"-H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs" }, - {"s:" , &nr_opt,"-s num Set the number of the been allocated hugepages" }, + {"H:" , &tst_hugepage_Hopt,"-H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs" }, + {"s:" , &tst_hugepage_nr_opt,"-s num Set the number of the been allocated hugepages" }, {} }, .setup = setup,
testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c +7 -7
@@ -92,25 +92,25 @@ void setup(void)if (tst_hugepages ==0 )tst_brk (TCONF ,"Not enough hugepages for testing!" ); -if (!Hopt) - Hopt =tst_get_tmpdir (); -SAFE_MOUNT ("none" , Hopt,"hugetlbfs" ,0 ,NULL ); +if (!tst_hugepage_Hopt) + tst_hugepage_Hopt =tst_get_tmpdir (); +SAFE_MOUNT ("none" , tst_hugepage_Hopt,"hugetlbfs" ,0 ,NULL ); -snprintf (TEMPFILE ,sizeof (TEMPFILE ),"%s/mmapfile%d" , Hopt,getpid ()); +snprintf (TEMPFILE ,sizeof (TEMPFILE ),"%s/mmapfile%d" , tst_hugepage_Hopt,getpid ()); }void cleanup (void ) {unlink (TEMPFILE ); -umount (Hopt); +umount (tst_hugepage_Hopt); }static struct tst_test test = { .needs_root =1 , .needs_tmpdir =1 , .options = (struct tst_option []) { - {"H:" , &Hopt,"-H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs" }, - {"s:" , &nr_opt,"-s num Set the number of the been allocated hugepages" }, + {"H:" , &tst_hugepage_Hopt,"-H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs" }, + {"s:" , &tst_hugepage_nr_opt,"-s num Set the number of the been allocated hugepages" }, {} }, .setup = setup,
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c +1 -1
@@ -173,7 +173,7 @@ static struct tst_test test = { .needs_root = 1, .needs_tmpdir = 1, .options = (struct tst_option []) { - {"s:" , &nr_opt,"-s num Set the number of the been allocated hugepages" }, + {"s:" , &tst_hugepage_nr_opt,"-s num Set the number of the been allocated hugepages" }, {} }, .tcnt = ARRAY_SIZE(tcases),
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat02.c +1 -1
@@ -100,7 +100,7 @@ static struct tst_test test = { .needs_root = 1, .needs_tmpdir = 1, .options = (struct tst_option []) { - {"s:" , &nr_opt,"-s num Set the number of the been allocated hugepages" }, + {"s:" , &tst_hugepage_nr_opt,"-s num Set the number of the been allocated hugepages" }, {} }, .tcnt = ARRAY_SIZE(tcases),
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat03.c +1 -1
@@ -95,7 +95,7 @@ static struct tst_test test = { .forks_child = 1, .needs_tmpdir = 1, .options = (struct tst_option []) { - {"s:" , &nr_opt,"-s num Set the number of the been allocated hugepages" }, + {"s:" , &tst_hugepage_nr_opt,"-s num Set the number of the been allocated hugepages" }, {} }, .test_all = verify_hugeshmat,
testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c +1 -1
@@ -303,7 +303,7 @@ static struct tst_test test = { .needs_root = 1, .forks_child = 1, .options = (struct tst_option []) { - {"s:" , &nr_opt,"-s num Set the number of the been allocated hugepages" }, + {"s:" , &tst_hugepage_nr_opt,"-s num Set the number of the been allocated hugepages" }, {} }, .setup = setup,
testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c +1 -1
@@ -105,7 +105,7 @@ static struct tst_test test = { .needs_root = 1, .needs_tmpdir = 1, .options = (struct tst_option []) { - {"s:" , &nr_opt,"-s num Set the number of the been allocated hugepages" }, + {"s:" , &tst_hugepage_nr_opt,"-s num Set the number of the been allocated hugepages" }, {} }, .setup = setup,
testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c +1 -1
@@ -128,7 +128,7 @@ static struct tst_test test = { .forks_child = 1, .needs_tmpdir = 1, .options = (struct tst_option []) { - {"s:" , &nr_opt,"-s num Set the number of the been allocated hugepages" }, + {"s:" , &tst_hugepage_nr_opt,"-s num Set the number of the been allocated hugepages" }, {} }, .setup = setup,
testcases/kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c +1 -1
@@ -146,7 +146,7 @@ void cleanup(void)static struct tst_test test = { .needs_root =1 , .options = (struct tst_option []) { - {"s:" , &nr_opt,"-s num Set the number of the been allocated hugepages" }, + {"s:" , &tst_hugepage_nr_opt,"-s num Set the number of the been allocated hugepages" }, {} }, .setup = setup,
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c +1 -1
@@ -72,7 +72,7 @@ static void cleanup(void)static struct tst_test test = { .needs_root =1 , .options = (struct tst_option []) { - {"s:" , &nr_opt,"-s num Set the number of the been allocated hugepages" }, + {"s:" , &tst_hugepage_nr_opt,"-s num Set the number of the been allocated hugepages" }, {} }, .setup = setup,
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c +1 -1
@@ -91,7 +91,7 @@ void cleanup(void)static struct tst_test test = { .needs_root =1 , .options = (struct tst_option []) { - {"s:" , &nr_opt,"-s num Set the number of the been allocated hugepages" }, + {"s:" , &tst_hugepage_nr_opt,"-s num Set the number of the been allocated hugepages" }, {} }, .setup = setup,
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c +1 -1
@@ -90,7 +90,7 @@ static void cleanup(void)static struct tst_test test = { .needs_root =1 , .options = (struct tst_option []) { - {"s:" , &nr_opt,"-s num Set the number of the been allocated hugepages" }, + {"s:" , &tst_hugepage_nr_opt,"-s num Set the number of the been allocated hugepages" }, {} }, .setup = setup,
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c +1 -1
@@ -86,7 +86,7 @@ void cleanup(void)static struct tst_test test = { .needs_root =1 , .options = (struct tst_option []) { - {"s:" , &nr_opt,"-s num Set the number of the been allocated hugepages" }, + {"s:" , &tst_hugepage_nr_opt,"-s num Set the number of the been allocated hugepages" }, {} }, .setup = setup,
Signature · 1 line
2.31.1
RFC PATCH 5/6 API: Add tst_ to hugepage opt vars
Quoted 2 lines · Richard Palethorpe via ltp
Signed-off-by Richard Palethorpe <[email protected]>
Signature · 2 lines
Regards, Li Wang
RFC PATCH 6/6 API: Check exported symbols
In reply to Richard PalethorpeAbort the build process if a new symbol is exported from the library without tst_ or safe_ prepended.
--- lib/Makefile | 12 +++++++ scripts/check_export_syms.sh | 64 ++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100755 scripts/check_export_syms.sh
lib/Makefile +12 -0
@@ -42,5 +42,17 @@ $(pc_file): test -d "$(@D)" || mkdir -p "$(@D)" install -m $(INSTALL_MODE) "$(builddir)/$(@F)" "$@" +CHECK_LIB ?= $(top_srcdir)/scripts/check_export_syms.sh +.PHONY: check_lib +check_lib: libltp.a +ifdef VERBOSE + $(CHECK_LIB) $< +else + @echo CHECK_LIB $< + @$(CHECK_LIB) $< +endif + +MAKE_TARGETS += check_lib + include $(top_srcdir)/include/mk/lib.mk include $(top_srcdir)/include/mk/generic_trunk_target.mk
scripts/check_export_syms.sh new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.31.1
RFC PATCH 6/6 API: Check exported symbols
Hi Richie,
Quoted 2 lines
Abort the build process if a new symbol is exported from the library without
tst_orsafe_prepended.
The PR does not work few on old toolchains [1], it fails on [2]:
awk: line 1: regular expression /parse_opts ... exceeds implementation size limit
It's one of the 2 awk calls in check_export_syms.sh, I suppose the other one. Maybe put non_prefix_syms into temporary file and then run awk on it?
Kind regards,
Petr
[1] https://travis-ci.org/github/pevik/ltp/builds/771465129
[2] https://travis-ci.org/github/pevik/ltp/jobs/771465135#L3115
RFC PATCH 6/6 API: Check exported symbols
Hello Petr,
Quoted 11 lines · Petr Vorel
Hi Richie,
Quoted 2 lines
Abort the build process if a new symbol is exported from the library without
tst_orsafe_prepended.The PR does not work few on old toolchains [1], it fails on [2]:
awk: line 1: regular expression /parse_opts ... exceeds implementation size limit
It's one of the 2 awk calls in
check_export_syms.sh, I suppose the other one. Maybe putnon_prefix_symsinto temporary file and then run awk on it?
I doubt it will help, it seems the ignore regex is too long. I'm not sure we need the script to run on old toolchains though.
Maybe we need a development mode configure flag?
Quoted 6 lines
Kind regards,
Petr[1] https://travis-ci.org/github/pevik/ltp/builds/771465129
[2] https://travis-ci.org/github/pevik/ltp/jobs/771465135#L3115
Signature · 2 lines
Thank you, Richard.
RFC PATCH 6/6 API: Check exported symbols
Hi Richie,
Quoted 13 lines
Hello Petr,
Quoted 8 lines · Petr Vorel
Hi Richie,
Quoted 2 lines
Abort the build process if a new symbol is exported from the library without
tst_orsafe_prepended.The PR does not work few on old toolchains [1], it fails on [2]:
awk: line 1: regular expression /parse_opts ... exceeds implementation size limit
Quoted 7 lines
Quoted 2 lines
It's one of the 2 awk calls in
check_export_syms.sh, I suppose the other one. Maybe putnon_prefix_symsinto temporary file and then run awk on it?I doubt it will help, it seems the ignore regex is too long. I'm not sure we need the script to run on old toolchains though.
Maybe we need a development mode configure flag?
I'll have a look into it, as I'd prefer to be fixed
(than repeat people on mailing list that this does not work on older distros). It's actually only on Debian stable or older.
Kind regards,
Petr
Quoted 5 lines
Quoted 5 lines
Kind regards,
Petr[1] https://travis-ci.org/github/pevik/ltp/builds/771465129
[2] https://travis-ci.org/github/pevik/ltp/jobs/771465135#L3115
RFC PATCH 6/6 API: Check exported symbols
Hello,
Quoted 18 lines · Petr Vorel
Hi Richie,
Quoted 15 lines
Hello Petr,
Quoted 11 lines · Petr Vorel
Hi Richie,
Quoted 2 lines
Abort the build process if a new symbol is exported from the library without
tst_orsafe_prepended.The PR does not work few on old toolchains [1], it fails on [2]:
awk: line 1: regular expression /parse_opts ... exceeds implementation size limit
It's one of the 2 awk calls in
check_export_syms.sh, I suppose the other one. Maybe putnon_prefix_symsinto temporary file and then run awk on it?
Quoted 8 lines
Quoted 4 lines
I doubt it will help, it seems the ignore regex is too long. I'm not sure we need the script to run on old toolchains though.
Maybe we need a development mode configure flag?
I'll have a look into it, as I'd prefer to be fixed
(than repeat people on mailing list that this does not work on older distros). It's actually only on Debian stable or older.
OK, I guess you can just shorten the regex by substituing "[lL]io_\w+" for all the lio stuff. Or filter by file instead.
Quoted 9 lines
Kind regards,
PetrQuoted 5 lines
Quoted 5 lines
Kind regards,
Petr[1] https://travis-ci.org/github/pevik/ltp/builds/771465129
[2] https://travis-ci.org/github/pevik/ltp/jobs/771465135#L3115
Signature · 2 lines
Thank you, Richard.
RFC PATCH 6/6 API: Check exported symbols
Hi!
Quoted 2 lines
OK, I guess you can just shorten the regex by substituing "[lL]io_\w+" for all the lio stuff. Or filter by file instead.
Another option would be moving the tlibio.c and random_range.c to libs/libltpobsolete/ and adding LTPLIBS flags for the few tests that actually use that code.
Signature · 2 lines
Cyril Hrubis [email protected]
RFC PATCH 6/6 API: Check exported symbols
Hi Cyril, Richie,
Quoted 7 lines
Hi!
Quoted 2 lines
OK, I guess you can just shorten the regex by substituing "[lL]io_\w+" for all the lio stuff. Or filter by file instead.
Another option would be moving the
tlibio.candrandom_range.cto libs/libltpobsolete/ and adding LTPLIBS flags for the few tests that actually use that code.
Thank you both for tips, both ways would work for me.
Kind regards,
Petr