<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The patch makes sense to me.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 25, 2019 at 5:02 PM Jan Stancek <<a href="mailto:jstancek@redhat.com">jstancek@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Prefix '?' was meant to silently ignore non-existing paths.<br>
However there are some /proc files which exist, but trigger<br>
error only after open/read:<br>
# ls -la /proc/sys/vm/nr_hugepages<br>
-rw-r--r--. 1 root root 0 Jun 25 04:17 /proc/sys/vm/nr_hugepages<br>
# cat /proc/sys/vm/nr_hugepages<br>
cat: /proc/sys/vm/nr_hugepages: Operation not supported<br>
<br>
This leads to unavoidable TBROK. Extend '?' flag to cover also open/read.<br>
<br>
Signed-off-by: Jan Stancek <<a href="mailto:jstancek@redhat.com" target="_blank">jstancek@redhat.com</a>><br>
---<br>
doc/test-writing-guidelines.txt | 9 +++++----<br>
lib/tst_sys_conf.c | 6 ++++++<br>
2 files changed, 11 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt<br>
index c6d4e001d72b..d0b7417f2cc8 100644<br>
--- a/doc/test-writing-guidelines.txt<br>
+++ b/doc/test-writing-guidelines.txt<br>
@@ -1515,10 +1515,11 @@ and restored at the end of the test. Only first line of a specified<br>
file is saved and restored.<br>
<br>
Pathnames can be optionally prefixed to specify how strictly (during<br>
-'store') are handled files that don't exist:<br>
- (no prefix) - test ends with TCONF<br>
- '?' - test prints info message and continues<br>
- '!' - test ends with TBROK<br>
+'store') are handled errors:<br>
+ (no prefix) - test ends with TCONF, if file doesn't exist<br>
+ '?' - test prints info message and continues,<br>
+ if file doesn't exist or open/read fails<br>
+ '!' - test ends with TBROK, if file doesn't exist<br>
<br>
'restore' is always strict and will TWARN if it encounters any error.<br>
<br>
diff --git a/lib/tst_sys_conf.c b/lib/tst_sys_conf.c<br>
index e767856ec148..bbe469936c99 100644<br>
--- a/lib/tst_sys_conf.c<br>
+++ b/lib/tst_sys_conf.c<br>
@@ -66,6 +66,9 @@ int tst_sys_conf_save(const char *path)<br>
<br>
fp = fopen(path, "r");<br>
if (fp == NULL) {<br>
+ if (flag == '?')<br>
+ return 1;<br>
+<br>
tst_brk(TBROK | TERRNO, "Failed to open FILE '%s' for reading",<br>
path);<br>
return 1;<br>
@@ -75,6 +78,9 @@ int tst_sys_conf_save(const char *path)<br>
fclose(fp);<br>
<br>
if (ret == NULL) {<br>
+ if (flag == '?')<br>
+ return 1;<br>
+<br>
tst_brk(TBROK | TERRNO, "Failed to read anything from '%s'",<br>
path);<br>
}<br>
-- <br>
1.8.3.1<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>