From 17a19676cdf803ec985aede9f38b8deaa971ac98 Mon Sep 17 00:00:00 2001 From: Alexander Mikhalitsyn Date: Thu, 5 May 2022 12:33:50 +0000 Subject: [PATCH] zdtm: handle the case when hugetlb isn't supported Fixes: e2e02bc83e ("zdtm: Add MAP_HUGETLB memory mapping test") Signed-off-by: Alexander Mikhalitsyn --- test/zdtm.py | 18 ++++++++++++------ test/zdtm/static/maps09.checkskip | 4 ++++ test/zdtm/static/maps10.checkskip | 1 + 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100755 test/zdtm/static/maps09.checkskip create mode 120000 test/zdtm/static/maps10.checkskip diff --git a/test/zdtm.py b/test/zdtm.py index 878c3e9cb..c011c79c0 100755 --- a/test/zdtm.py +++ b/test/zdtm.py @@ -2584,12 +2584,18 @@ def clean_stuff(opts): def set_nr_hugepages(nr): - orig_hugepages = 0 - with open("/proc/sys/vm/nr_hugepages", "r") as f: - orig_hugepages = int(f.read()) - with open("/proc/sys/vm/nr_hugepages", "w") as f: - f.write("{}\n".format(nr)) - return orig_hugepages + try: + orig_hugepages = 0 + with open("/proc/sys/vm/nr_hugepages", "r") as f: + orig_hugepages = int(f.read()) + with open("/proc/sys/vm/nr_hugepages", "w") as f: + f.write("{}\n".format(nr)) + return orig_hugepages + except OSError as err: + if err.errno != errno.EOPNOTSUPP: + raise + + return 0 def get_cli_args(): diff --git a/test/zdtm/static/maps09.checkskip b/test/zdtm/static/maps09.checkskip new file mode 100755 index 000000000..df2370815 --- /dev/null +++ b/test/zdtm/static/maps09.checkskip @@ -0,0 +1,4 @@ +#!/bin/bash + +# will fail with EOPNOTSUPP +cat /proc/sys/vm/nr_hugepages &> /dev/null diff --git a/test/zdtm/static/maps10.checkskip b/test/zdtm/static/maps10.checkskip new file mode 120000 index 000000000..fb42f0f44 --- /dev/null +++ b/test/zdtm/static/maps10.checkskip @@ -0,0 +1 @@ +maps09.checkskip \ No newline at end of file