Message ID | 20220303153131.3372-3-mdoucha@suse.cz |
---|---|
State | Superseded |
Headers | show |
Series | [1/3] quotactl06: Replace tst_brk(TFAIL) with TBROK | expand |
Hi Martin > When setup() exits with TCONF before TESTDIR1 gets created, cleanup() will > trigger TWARN when it tries to delete it. Check whether the directory exists > before calling SAFE_RMDIR(). > > Signed-off-by: Martin Doucha<mdoucha@suse.cz> > --- > testcases/kernel/syscalls/quotactl/quotactl06.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/testcases/kernel/syscalls/quotactl/quotactl06.c b/testcases/kernel/syscalls/quotactl/quotactl06.c > index 8e9a17393..d470486d5 100644 > --- a/testcases/kernel/syscalls/quotactl/quotactl06.c > +++ b/testcases/kernel/syscalls/quotactl/quotactl06.c > @@ -207,7 +207,9 @@ static void setup(void) > static void cleanup(void) > { > SAFE_UNLINK(USRPATH); It seems we also should check USRPATH whether existed. Best Regards Yang Xu > - SAFE_RMDIR(TESTDIR1); > + > + if (!access(TESTDIR1, F_OK)) > + SAFE_RMDIR(TESTDIR1); > } > > static struct tst_test test = {
On 04. 03. 22 2:38, xuyang2018.jy@fujitsu.com wrote: > Hi Martin >> When setup() exits with TCONF before TESTDIR1 gets created, cleanup() will >> trigger TWARN when it tries to delete it. Check whether the directory exists >> before calling SAFE_RMDIR(). >> >> Signed-off-by: Martin Doucha<mdoucha@suse.cz> >> --- >> testcases/kernel/syscalls/quotactl/quotactl06.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/testcases/kernel/syscalls/quotactl/quotactl06.c b/testcases/kernel/syscalls/quotactl/quotactl06.c >> index 8e9a17393..d470486d5 100644 >> --- a/testcases/kernel/syscalls/quotactl/quotactl06.c >> +++ b/testcases/kernel/syscalls/quotactl/quotactl06.c >> @@ -207,7 +207,9 @@ static void setup(void) >> static void cleanup(void) >> { >> SAFE_UNLINK(USRPATH); > It seems we also should check USRPATH whether existed. If I understand correctly, the file will be created by mount(), even before setup() gets executed. So if the file doesn't exist during cleanup(), the error will be valid.
Hi Martin > On 04. 03. 22 2:38, xuyang2018.jy@fujitsu.com wrote: >> Hi Martin >>> When setup() exits with TCONF before TESTDIR1 gets created, cleanup() will >>> trigger TWARN when it tries to delete it. Check whether the directory exists >>> before calling SAFE_RMDIR(). >>> >>> Signed-off-by: Martin Doucha<mdoucha@suse.cz> >>> --- >>> testcases/kernel/syscalls/quotactl/quotactl06.c | 4 +++- >>> 1 file changed, 3 insertions(+), 1 deletion(-) >>> >>> diff --git a/testcases/kernel/syscalls/quotactl/quotactl06.c b/testcases/kernel/syscalls/quotactl/quotactl06.c >>> index 8e9a17393..d470486d5 100644 >>> --- a/testcases/kernel/syscalls/quotactl/quotactl06.c >>> +++ b/testcases/kernel/syscalls/quotactl/quotactl06.c >>> @@ -207,7 +207,9 @@ static void setup(void) >>> static void cleanup(void) >>> { >>> SAFE_UNLINK(USRPATH); >> It seems we also should check USRPATH whether existed. > > If I understand correctly, the file will be created by mount(), even > before setup() gets executed. So if the file doesn't exist during > cleanup(), the error will be valid. The USRPATH file is generated by quotacheck command. Best Regards Yang Xu >
diff --git a/testcases/kernel/syscalls/quotactl/quotactl06.c b/testcases/kernel/syscalls/quotactl/quotactl06.c index 8e9a17393..d470486d5 100644 --- a/testcases/kernel/syscalls/quotactl/quotactl06.c +++ b/testcases/kernel/syscalls/quotactl/quotactl06.c @@ -207,7 +207,9 @@ static void setup(void) static void cleanup(void) { SAFE_UNLINK(USRPATH); - SAFE_RMDIR(TESTDIR1); + + if (!access(TESTDIR1, F_OK)) + SAFE_RMDIR(TESTDIR1); } static struct tst_test test = {
When setup() exits with TCONF before TESTDIR1 gets created, cleanup() will trigger TWARN when it tries to delete it. Check whether the directory exists before calling SAFE_RMDIR(). Signed-off-by: Martin Doucha <mdoucha@suse.cz> --- testcases/kernel/syscalls/quotactl/quotactl06.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)