DPDK patches and discussions
 help / color / mirror / Atom feed
From: Reshma Pattan <reshma.pattan@intel.com>
To: thomas@monjalon.net, dev@dpdk.org
Cc: anatoly.burakov@intel.com, jananeex.m.parthasarathy@intel.com,
	stable@dpdk.org
Subject: [dpdk-dev] [PATCH v4 5/9] autotest: improve filtering
Date: Tue, 17 Jul 2018 11:39:52 +0100	[thread overview]
Message-ID: <1531823996-18967-6-git-send-email-reshma.pattan@intel.com> (raw)
In-Reply-To: <cover.1528404133.git.anatoly.burakov@intel.com>

Improve code for filtering test groups. Also, move reading binary
symbols into filtering stage, so that tests that are meant to be
skipped are never attempted to be executed in the first place.
Before running tests, print out any tests that were skipped because
they weren't compiled.

Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/autotest_runner.py | 118 ++++++++++++++++++++++++-------------------
 1 file changed, 66 insertions(+), 52 deletions(-)

diff --git a/test/test/autotest_runner.py b/test/test/autotest_runner.py
index d9d5f7a97..c98ec2a57 100644
--- a/test/test/autotest_runner.py
+++ b/test/test/autotest_runner.py
@@ -95,13 +95,6 @@ def run_test_group(cmdline, target, test_group):
     results.append((0, "Success", "Start %s" % test_group["Prefix"],
                     time.time() - start_time, startuplog.getvalue(), None))
 
-    # parse the binary for available test commands
-    binary = cmdline.split()[0]
-    stripped = 'not stripped' not in subprocess.check_output(['file', binary])
-    if not stripped:
-        symbols = subprocess.check_output(['nm', binary]).decode('utf-8')
-        avail_cmds = re.findall('test_register_(\w+)', symbols)
-
     # run all tests in test group
     for test in test_group["Tests"]:
 
@@ -121,10 +114,7 @@ def run_test_group(cmdline, target, test_group):
             print("\n%s %s\n" % ("-" * 20, test["Name"]), file=logfile)
 
             # run test function associated with the test
-            if stripped or test["Command"] in avail_cmds:
-                result = test["Func"](child, test["Command"])
-            else:
-                result = (0, "Skipped [Not Available]")
+            result = test["Func"](child, test["Command"])
 
             # make a note when the test was finished
             end_time = time.time()
@@ -186,8 +176,10 @@ class AutotestRunner:
     def __init__(self, cmdline, target, blacklist, whitelist):
         self.cmdline = cmdline
         self.target = target
+        self.binary = cmdline.split()[0]
         self.blacklist = blacklist
         self.whitelist = whitelist
+        self.skipped = []
 
         # log file filename
         logfile = "%s.log" % target
@@ -276,53 +268,58 @@ def __process_results(self, results):
             if i != 0:
                 self.csvwriter.writerow([test_name, test_result, result_str])
 
-    # this function iterates over test groups and removes each
-    # test that is not in whitelist/blacklist
-    def __filter_groups(self, test_groups):
-        groups_to_remove = []
-
-        # filter out tests from parallel test groups
-        for i, test_group in enumerate(test_groups):
-
-            # iterate over a copy so that we could safely delete individual
-            # tests
-            for test in test_group["Tests"][:]:
-                test_id = test["Command"]
-
-                # dump tests are specified in full e.g. "Dump_mempool"
-                if "_autotest" in test_id:
-                    test_id = test_id[:-len("_autotest")]
-
-                # filter out blacklisted/whitelisted tests
-                if self.blacklist and test_id in self.blacklist:
-                    test_group["Tests"].remove(test)
-                    continue
-                if self.whitelist and test_id not in self.whitelist:
-                    test_group["Tests"].remove(test)
-                    continue
-
-            # modify or remove original group
-            if len(test_group["Tests"]) > 0:
-                test_groups[i] = test_group
-            else:
-                # remember which groups should be deleted
-                # put the numbers backwards so that we start
-                # deleting from the end, not from the beginning
-                groups_to_remove.insert(0, i)
+    # this function checks individual test and decides if this test should be in
+    # the group by comparing it against  whitelist/blacklist. it also checks if
+    # the test is compiled into the binary, and marks it as skipped if necessary
+    def __filter_test(self, test):
+        test_cmd = test["Command"]
+        test_id = test_cmd
+
+        # dump tests are specified in full e.g. "Dump_mempool"
+        if "_autotest" in test_id:
+            test_id = test_id[:-len("_autotest")]
+
+        # filter out blacklisted/whitelisted tests
+        if self.blacklist and test_id in self.blacklist:
+            return False
+        if self.whitelist and test_id not in self.whitelist:
+            return False
+
+        # if test wasn't compiled in, remove it as well
+
+        # parse the binary for available test commands
+        stripped = 'not stripped' not in \
+                   subprocess.check_output(['file', self.binary])
+        if not stripped:
+            symbols = subprocess.check_output(['nm',
+                                               self.binary]).decode('utf-8')
+            avail_cmds = re.findall('test_register_(\w+)', symbols)
+
+            if test_cmd not in avail_cmds:
+                # notify user
+                result = 0, "Skipped [Not compiled]", test_id, 0, "", None
+                self.skipped.append(tuple(result))
+                return False
 
-        # remove test groups that need to be removed
-        for i in groups_to_remove:
-            del test_groups[i]
+        return True
 
-        return test_groups
+    def __filter_group(self, group):
+        group["Tests"] = list(filter(self.__filter_test, group["Tests"]))
+        return len(group["Tests"]) > 0
 
     # iterate over test groups and run tests associated with them
     def run_all_tests(self):
         # filter groups
-        self.parallel_test_groups = \
-            self.__filter_groups(self.parallel_test_groups)
-        self.non_parallel_test_groups = \
-            self.__filter_groups(self.non_parallel_test_groups)
+        # for each test group, check all tests against the filter, then remove
+        # all groups that don't have any tests
+        self.parallel_test_groups = list(
+            filter(self.__filter_group,
+                   self.parallel_test_groups)
+        )
+        self.non_parallel_test_groups = list(
+            filter(self.__filter_group,
+                   self.non_parallel_test_groups)
+        )
 
         # create a pool of worker threads
         pool = multiprocessing.Pool(processes=1)
@@ -338,6 +335,23 @@ def run_all_tests(self):
                   "Test".center(9) + "Total".center(9))
             print("=" * 80)
 
+            # print out skipped autotests if there were any
+            if len(self.skipped):
+                print("Skipped autotests:")
+
+                # print out any skipped tests
+                for result in self.skipped:
+                    # unpack result tuple
+                    test_result, result_str, test_name, _, _, _ = result
+                    self.csvwriter.writerow([test_name, test_result,
+                                             result_str])
+
+                    t = ("%s:" % test_name).ljust(30)
+                    t += result_str.ljust(29)
+                    t += "[00m 00s]"
+
+                    print(t)
+
             # make a note of tests start time
             self.start = time.time()
 
-- 
2.14.4

  parent reply	other threads:[~2018-07-17 10:40 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-07 21:01 [dpdk-dev] [PATCH 0/7] Make unit tests great again Anatoly Burakov
2018-06-07 21:01 ` [dpdk-dev] [PATCH 1/7] autotest: fix printing Anatoly Burakov
2018-06-07 21:01 ` [dpdk-dev] [PATCH 2/7] autotest: fix invalid code on reports Anatoly Burakov
2018-06-07 21:01 ` [dpdk-dev] [PATCH 3/7] autotest: make autotest runner python 2/3 compliant Anatoly Burakov
2018-06-07 21:01 ` [dpdk-dev] [PATCH 4/7] autotest: visually separate different test categories Anatoly Burakov
2018-06-07 21:01 ` [dpdk-dev] [PATCH 5/7] autotest: improve filtering Anatoly Burakov
2018-06-07 21:02 ` [dpdk-dev] [PATCH 6/7] autotest: remove autotest grouping Anatoly Burakov
2018-06-07 21:02 ` [dpdk-dev] [PATCH 7/7] autotest: properly parallelize unit tests Anatoly Burakov
2018-06-12 13:07 ` [dpdk-dev] [PATCH 0/7] Make unit tests great again Thomas Monjalon
2018-06-13  8:38   ` Burakov, Anatoly
2018-06-13 10:29     ` Bruce Richardson
2018-07-13 16:19 ` [dpdk-dev] [PATCH v2 00/10] " Reshma Pattan
2018-07-13 16:19 ` [dpdk-dev] [PATCH v2 01/10] autotest: fix printing Reshma Pattan
2018-07-13 16:20 ` [dpdk-dev] [PATCH v2 02/10] autotest: fix invalid code on reports Reshma Pattan
2018-07-13 16:20 ` [dpdk-dev] [PATCH v2 03/10] autotest: make autotest runner python 2/3 compliant Reshma Pattan
2018-07-13 16:20 ` [dpdk-dev] [PATCH v2 04/10] autotest: visually separate different test categories Reshma Pattan
2018-07-13 16:20 ` [dpdk-dev] [PATCH v2 05/10] autotest: improve filtering Reshma Pattan
2018-07-13 16:20 ` [dpdk-dev] [PATCH v2 06/10] autotest: remove autotest grouping Reshma Pattan
2018-07-13 16:20 ` [dpdk-dev] [PATCH v2 07/10] autotest: properly parallelize unit tests Reshma Pattan
2018-07-13 16:20 ` [dpdk-dev] [PATCH v2 08/10] autotest: add new test cases to autotest Reshma Pattan
2018-07-13 16:41   ` Burakov, Anatoly
2018-07-16 13:29     ` Pattan, Reshma
2018-07-13 16:20 ` [dpdk-dev] [PATCH v2 09/10] autotest: update result for skipped test cases Reshma Pattan
2018-07-13 16:42   ` Burakov, Anatoly
2018-07-13 16:20 ` [dpdk-dev] [PATCH v2 10/10] mk: update make targets for classified testcases Reshma Pattan
2018-07-16 14:12 ` [dpdk-dev] [PATCH v3 0/9] Make unit tests great again Reshma Pattan
2018-07-16 14:12 ` [dpdk-dev] [PATCH v3 1/9] autotest: fix printing Reshma Pattan
2018-07-16 14:12 ` [dpdk-dev] [PATCH v3 2/9] autotest: fix invalid code on reports Reshma Pattan
2018-07-16 14:12 ` [dpdk-dev] [PATCH v3 3/9] autotest: make autotest runner python 2/3 compliant Reshma Pattan
2018-07-16 14:12 ` [dpdk-dev] [PATCH v3 4/9] autotest: visually separate different test categories Reshma Pattan
2018-07-16 14:12 ` [dpdk-dev] [PATCH v3 5/9] autotest: improve filtering Reshma Pattan
2018-07-16 14:12 ` [dpdk-dev] [PATCH v3 6/9] autotest: remove autotest grouping Reshma Pattan
2018-07-16 14:12 ` [dpdk-dev] [PATCH v3 7/9] autotest: properly parallelize unit tests Reshma Pattan
2018-07-16 14:12 ` [dpdk-dev] [PATCH v3 8/9] autotest: update autotest test case list Reshma Pattan
2018-07-16 15:16   ` Burakov, Anatoly
2018-07-17  9:18     ` Pattan, Reshma
2018-07-17  9:23       ` Burakov, Anatoly
2018-07-17  9:45         ` Pattan, Reshma
2018-07-17 10:10           ` Burakov, Anatoly
2018-07-16 14:12 ` [dpdk-dev] [PATCH v3 9/9] mk: update make targets for classified testcases Reshma Pattan
2018-07-17 10:39 ` [dpdk-dev] [PATCH v4 0/9] Make unit tests great again Reshma Pattan
2018-07-17 10:39 ` [dpdk-dev] [PATCH v4 1/9] autotest: fix printing Reshma Pattan
2018-07-17 10:39 ` [dpdk-dev] [PATCH v4 2/9] autotest: fix invalid code on reports Reshma Pattan
2018-07-17 10:39 ` [dpdk-dev] [PATCH v4 3/9] autotest: make autotest runner python 2/3 compliant Reshma Pattan
2018-07-17 10:39 ` [dpdk-dev] [PATCH v4 4/9] autotest: visually separate different test categories Reshma Pattan
2018-07-17 10:39 ` Reshma Pattan [this message]
2018-07-17 10:39 ` [dpdk-dev] [PATCH v4 6/9] autotest: remove autotest grouping Reshma Pattan
2018-07-17 10:39 ` [dpdk-dev] [PATCH v4 7/9] autotest: properly parallelize unit tests Reshma Pattan
2018-07-17 10:39 ` [dpdk-dev] [PATCH v4 8/9] autotest: update autotest test case list Reshma Pattan
2018-07-17 10:39 ` [dpdk-dev] [PATCH v4 9/9] mk: update make targets for classified testcases Reshma Pattan
2018-07-17 13:15 [dpdk-dev] [PATCH v4 0/9] Make unit tests great again Reshma Pattan
2018-07-17 13:15 ` [dpdk-dev] [PATCH v4 5/9] autotest: improve filtering Reshma Pattan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1531823996-18967-6-git-send-email-reshma.pattan@intel.com \
    --to=reshma.pattan@intel.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=jananeex.m.parthasarathy@intel.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).