Add ELOOP error number test in chdir01.c for chdir(2)

Signed-off-by: Zeng Linggang <[email protected]>
---
 testcases/kernel/syscalls/chdir/chdir01.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/chdir/chdir01.c 
b/testcases/kernel/syscalls/chdir/chdir01.c
index 04fb8b4..c4e74fb 100644
--- a/testcases/kernel/syscalls/chdir/chdir01.c
+++ b/testcases/kernel/syscalls/chdir/chdir01.c
@@ -59,9 +59,9 @@
 #include "safe_macros.h"
 
 char *TCID = "chdir01";
-int TST_TOTAL = 1;
+int TST_TOTAL = 2;
 
-int exp_enos[] = { ENOTDIR, 0 };
+int exp_enos[] = { ENOTDIR, ELOOP, 0 };
 
 void setup(void);
 void cleanup(void);
@@ -120,6 +120,23 @@ int main(int ac, char **av)
 
                SAFE_CHDIR(cleanup, "..");
 
+               /* ELOOP */
+               SAFE_SYMLINK(cleanup, "test_eloop1", "test_eloop2");
+               SAFE_SYMLINK(cleanup, "test_eloop2", "test_eloop1");
+
+               TEST(chdir("test_eloop1"));
+
+               if (TEST_RETURN != -1) {
+                       tst_resm(TFAIL, "call succeeded unexpectedly");
+               } else if (TEST_ERRNO != ELOOP) {
+                       tst_resm(TFAIL | TTERRNO,
+                                "failed unexpectedly; wanted ELOOP");
+               } else {
+                       tst_resm(TPASS, "failed as expected with ELOOP");
+               }
+
+               SAFE_UNLINK(cleanup, "test_eloop1");
+               SAFE_UNLINK(cleanup, "test_eloop2");
        }
        cleanup();
 
-- 
1.8.2.1



------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to