Message ID | 20230512062408.3436005-1-renmm6@chinaunicom.cn (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [kvm-unit-tests,v2] run_tests: add list tests name option on command line | expand |
On Fri, May 12, 2023 at 02:24:08PM +0800, 任敏敏(联通集团联通数字科技有限公司本部) wrote: > From: rminmin <renmm6@chinaunicom.cn> > > Add '-l | --list' option on command line to output > all tests name only, and cloud be filtered by group ^ could > with '-g | --group' option. > > E.g. > List all vmx group tests name: > $ ./run_tests.sh -g vmx -l > > List all tests name: > $ ./run_tests.sh -l > > Signed-off-by: rminmin <renmm6@chinaunicom.cn> > --- > run_tests.sh | 21 +++++++++++++++++++-- > 1 file changed, 19 insertions(+), 2 deletions(-) > > diff --git a/run_tests.sh b/run_tests.sh > index f61e005..af25f24 100755 > --- a/run_tests.sh > +++ b/run_tests.sh > @@ -15,7 +15,7 @@ function usage() > { > cat <<EOF > > -Usage: $0 [-h] [-v] [-a] [-g group] [-j NUM-TASKS] [-t] > +Usage: $0 [-h] [-v] [-a] [-g group] [-j NUM-TASKS] [-t] [-l] > > -h, --help Output this help text > -v, --verbose Enables verbose mode > @@ -24,6 +24,7 @@ Usage: $0 [-h] [-v] [-a] [-g group] [-j NUM-TASKS] [-t] > -g, --group Only execute tests in the given group > -j, --parallel Execute tests in parallel > -t, --tap13 Output test results in TAP format > + -l, --list Only output all tests list > > Set the environment variable QEMU=/path/to/qemu-system-ARCH to > specify the appropriate qemu binary for ARCH-run. > @@ -42,7 +43,8 @@ if [ $? -ne 4 ]; then > fi > > only_tests="" > -args=$(getopt -u -o ag:htj:v -l all,group:,help,tap13,parallel:,verbose -- $*) > +list_tests="" > +args=$(getopt -u -o ag:htj:v:l -l all,group:,help,tap13,parallel:,verbose:,list -- $*) > [ $? -ne 0 ] && exit 2; > set -- $args; > while [ $# -gt 0 ]; do > @@ -73,6 +75,9 @@ while [ $# -gt 0 ]; do > -t | --tap13) > tap_output="yes" > ;; > + -l | --list) > + list_tests="yes" > + ;; > --) > ;; > *) > @@ -154,6 +159,18 @@ function run_task() > : ${unittest_run_queues:=1} > config=$TEST_DIR/unittests.cfg > > +print_testname() > +{ > + if [ -n "$only_group" ] && ! find_word "$only_group" "$groups"; then It's a bit cleaner to use the local variable for groups. for_each_unittest will put it in $2, so print_testname() { local testname=$1 local groups=$2 if [ -n "$only_group" ] && ! find_word "$only_group" "$groups"; then return fi echo "$testname" } > + return > + fi > + echo "$1" > +} > +if [[ $list_tests == "yes" ]]; then > + for_each_unittest $config print_testname > + exit > +fi > + > rm -rf $unittest_log_dir.old > [ -d $unittest_log_dir ] && mv $unittest_log_dir $unittest_log_dir.old > mkdir $unittest_log_dir || exit 2 > -- > 2.33.0 > Thanks, drew
diff --git a/run_tests.sh b/run_tests.sh index f61e005..af25f24 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -15,7 +15,7 @@ function usage() { cat <<EOF -Usage: $0 [-h] [-v] [-a] [-g group] [-j NUM-TASKS] [-t] +Usage: $0 [-h] [-v] [-a] [-g group] [-j NUM-TASKS] [-t] [-l] -h, --help Output this help text -v, --verbose Enables verbose mode @@ -24,6 +24,7 @@ Usage: $0 [-h] [-v] [-a] [-g group] [-j NUM-TASKS] [-t] -g, --group Only execute tests in the given group -j, --parallel Execute tests in parallel -t, --tap13 Output test results in TAP format + -l, --list Only output all tests list Set the environment variable QEMU=/path/to/qemu-system-ARCH to specify the appropriate qemu binary for ARCH-run. @@ -42,7 +43,8 @@ if [ $? -ne 4 ]; then fi only_tests="" -args=$(getopt -u -o ag:htj:v -l all,group:,help,tap13,parallel:,verbose -- $*) +list_tests="" +args=$(getopt -u -o ag:htj:v:l -l all,group:,help,tap13,parallel:,verbose:,list -- $*) [ $? -ne 0 ] && exit 2; set -- $args; while [ $# -gt 0 ]; do @@ -73,6 +75,9 @@ while [ $# -gt 0 ]; do -t | --tap13) tap_output="yes" ;; + -l | --list) + list_tests="yes" + ;; --) ;; *) @@ -154,6 +159,18 @@ function run_task() : ${unittest_run_queues:=1} config=$TEST_DIR/unittests.cfg +print_testname() +{ + if [ -n "$only_group" ] && ! find_word "$only_group" "$groups"; then + return + fi + echo "$1" +} +if [[ $list_tests == "yes" ]]; then + for_each_unittest $config print_testname + exit +fi + rm -rf $unittest_log_dir.old [ -d $unittest_log_dir ] && mv $unittest_log_dir $unittest_log_dir.old mkdir $unittest_log_dir || exit 2