[Piglit] [PATCH 1/9] check.py: a small utility for checking missing tests.
Dylan Baker
baker.dylan.c at gmail.com
Wed Sep 2 12:51:16 PDT 2015
I've included this so other can see what I was doing, I don't think it
really needs to be committed, but it could be if people wanted.
Though, it probably needs some cleanup before merge.
---
check.py | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
create mode 100755 check.py
diff --git a/check.py b/check.py
new file mode 100755
index 0000000..22e398a
--- /dev/null
+++ b/check.py
@@ -0,0 +1,87 @@
+#!/usr/bin/python2
+# Copyright (c) 2015 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+"""Small script that checks that all binaries are in a profile."""
+
+from __future__ import print_function, absolute_import, division
+import os
+import stat
+
+from tests.all import profile
+
+DIR = os.path.abspath(os.path.join(os.getcwd(), 'bin'))
+
+
+def make_called_binary_set():
+ """Create a set of binaries that are actually called in the profile."""
+ bins = set()
+ for test in profile.test_list.itervalues():
+ bins.add(os.path.basename(test.command[0]))
+ return bins
+
+
+def _is_executable(filename):
+ """Check if a filepath is an executable.
+
+ Even if the executable bit is set, it could still be a shell script, or a
+ .c file, or something else that has the bit set wrongly.
+
+ """
+ if stat.S_IXUSR & os.stat(filename)[stat.ST_MODE]:
+ if os.path.splitext(filename)[1]:
+ return False
+ else:
+ return True
+ return False
+
+
+def make_actual_binary_set():
+ """Create a set of binaries that are in the path."""
+ bins = set()
+ for dirpath, _, filenames in os.walk(DIR):
+ for filename in filenames:
+ filename = os.path.join(dirpath, filename)
+ if _is_executable(filename):
+ bins.add(os.path.basename(filename))
+ return bins
+
+
+def compare_sets():
+ """Find the binaries that are missing from called."""
+ called = make_called_binary_set()
+ actual = make_actual_binary_set()
+
+ missing = set()
+ for x in actual:
+ if x not in called:
+ missing.add(x)
+
+ return missing
+
+
+def main():
+ """Main function."""
+ missing = compare_sets()
+ print('\n'.join(missing))
+
+
+if __name__ == '__main__':
+ main()
--
2.5.1
More information about the Piglit
mailing list