2022-04-02 08:02:20 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# This script lists the GNU failing tests by size
|
|
|
|
# Just like with util/run-gnu-test.sh, we expect the gnu sources
|
|
|
|
# to be in ../
|
|
|
|
import urllib.request
|
|
|
|
|
|
|
|
import urllib
|
|
|
|
import os
|
|
|
|
import glob
|
|
|
|
import json
|
2023-03-25 07:48:33 +00:00
|
|
|
import sys
|
2022-04-02 08:02:20 +00:00
|
|
|
|
|
|
|
base = "../gnu/tests/"
|
2024-01-03 19:41:44 +00:00
|
|
|
|
|
|
|
# Try to download the file, use local copy if download fails
|
|
|
|
result_json = "result.json"
|
|
|
|
try:
|
|
|
|
urllib.request.urlretrieve(
|
|
|
|
"https://raw.githubusercontent.com/uutils/coreutils-tracking/main/gnu-full-result.json",
|
|
|
|
result_json
|
|
|
|
)
|
|
|
|
except Exception as e:
|
|
|
|
print(f"Failed to download the file: {e}")
|
|
|
|
if not os.path.exists(result_json):
|
|
|
|
print(f"Local file '{result_json}' not found. Exiting.")
|
|
|
|
sys.exit(1)
|
|
|
|
else:
|
|
|
|
print(f"Using local file '{result_json}'.")
|
2022-04-02 08:02:20 +00:00
|
|
|
|
2022-04-06 09:03:13 +00:00
|
|
|
types = ("/*/*.sh", "/*/*.pl", "/*/*.xpl")
|
2022-04-02 08:02:20 +00:00
|
|
|
|
2022-04-06 09:03:13 +00:00
|
|
|
tests = []
|
2023-05-15 19:46:07 +00:00
|
|
|
error_tests = []
|
|
|
|
skip_tests = []
|
2022-08-14 20:23:11 +00:00
|
|
|
|
2022-04-06 09:03:13 +00:00
|
|
|
for files in types:
|
|
|
|
tests.extend(glob.glob(base + files))
|
2022-04-02 08:02:20 +00:00
|
|
|
# sort by size
|
|
|
|
list_of_files = sorted(tests, key=lambda x: os.stat(x).st_size)
|
|
|
|
|
2022-08-14 20:23:11 +00:00
|
|
|
|
|
|
|
def show_list(l):
|
|
|
|
# Remove the factor tests and reverse the list (bigger first)
|
|
|
|
tests = list(filter(lambda k: "factor" not in k, l))
|
|
|
|
|
|
|
|
for f in reversed(tests):
|
2024-01-02 19:33:05 +00:00
|
|
|
if contains_require_root(f):
|
|
|
|
print("%s: %s / require_root" % (f, os.stat(f).st_size))
|
|
|
|
else:
|
|
|
|
print("%s: %s" % (f, os.stat(f).st_size))
|
2022-08-14 20:23:11 +00:00
|
|
|
print("")
|
|
|
|
print("%s tests remaining" % len(tests))
|
|
|
|
|
|
|
|
|
2024-01-02 19:33:05 +00:00
|
|
|
def contains_require_root(file_path):
|
|
|
|
try:
|
|
|
|
with open(file_path, "r") as file:
|
|
|
|
return "require_root_" in file.read()
|
|
|
|
except IOError:
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
2022-04-02 08:02:20 +00:00
|
|
|
with open("result.json", "r") as json_file:
|
|
|
|
data = json.load(json_file)
|
|
|
|
|
|
|
|
for d in data:
|
|
|
|
for e in data[d]:
|
|
|
|
# Not all the tests are .sh files, rename them if not.
|
|
|
|
script = e.replace(".log", ".sh")
|
2022-04-06 09:03:27 +00:00
|
|
|
a = f"{base}{d}/{script}"
|
2022-04-02 08:02:20 +00:00
|
|
|
if not os.path.exists(a):
|
|
|
|
a = a.replace(".sh", ".pl")
|
|
|
|
if not os.path.exists(a):
|
|
|
|
a = a.replace(".pl", ".xpl")
|
|
|
|
|
|
|
|
# the tests pass, we don't care anymore
|
2022-04-06 07:24:20 +00:00
|
|
|
if data[d][e] == "PASS":
|
2023-03-25 07:48:33 +00:00
|
|
|
try:
|
|
|
|
list_of_files.remove(a)
|
|
|
|
except ValueError:
|
|
|
|
print("Could not find test '%s'. Maybe update the GNU repo?" % a)
|
|
|
|
sys.exit(1)
|
2022-04-02 08:02:20 +00:00
|
|
|
|
2023-05-15 19:46:07 +00:00
|
|
|
# if it is SKIP, show it
|
|
|
|
if data[d][e] == "SKIP":
|
2022-08-14 20:23:11 +00:00
|
|
|
list_of_files.remove(a)
|
2023-05-15 19:46:07 +00:00
|
|
|
skip_tests.append(a)
|
2022-08-14 20:23:11 +00:00
|
|
|
|
2023-05-15 19:46:07 +00:00
|
|
|
# if it is ERROR, show it
|
|
|
|
if data[d][e] == "ERROR":
|
|
|
|
list_of_files.remove(a)
|
|
|
|
error_tests.append(a)
|
2022-04-02 08:02:20 +00:00
|
|
|
|
2023-05-15 19:46:07 +00:00
|
|
|
print("===============")
|
|
|
|
print("SKIP tests:")
|
|
|
|
show_list(skip_tests)
|
|
|
|
print("")
|
|
|
|
print("===============")
|
|
|
|
print("ERROR tests:")
|
|
|
|
show_list(error_tests)
|
2022-04-02 08:02:20 +00:00
|
|
|
print("")
|
2022-08-14 20:23:11 +00:00
|
|
|
print("===============")
|
|
|
|
print("FAIL tests:")
|
|
|
|
show_list(list_of_files)
|