Skip to contentSkip to conversation

Allow swapon03 test to pass with unknown max_swapfiles

PATCH In review Murlin Wenzel 3 participants 4 messages Aug 2, 2010 – Aug 6, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow swapon03 test to pass with unknown max_swapfiles

This patch will allow swapon03 test case to pass even when max_swapfiles is not known. Create maximum possible number of swapfiles during setup, then verify that attempting to create one more swapfile will return EPERM. This is meant to change as little as possible of the existing code.

testcases/kernel/syscalls/swapon/swapon03.c renamed from testcases/kernel/syscalls/swapon/swapon03.c.orig +12 -8
@@ -142,8 +142,7 @@
 		/* Check return code */
 		if ((TEST_RETURN == -1) && (TEST_ERRNO == expected_errno)) {
 			tst_resm(TPASS, "swapon(2) got expected failure;"
-				 " Got errno - %d, probably your"
-				 " MAX_SWAPFILES is 30", expected_errno);
+				 " Got errno = %d," , expected_errno);
 		} else if (TEST_RETURN < 0) {
 			tst_resm(TFAIL, "swapon(2) failed to produce"
 				 " expected error: %d, got %d (%s)."
@@ -174,7 +173,7 @@
 				    && (TEST_ERRNO == expected_errno)) {
 					tst_resm(TPASS,
 						 "swapon(2) got expected failure;"
-						 " Got errno - %d, probably your"
+						 " Got errno = %d, probably your"
 						 " MAX_SWAPFILES is 32",
 						 expected_errno);
 				} else {
@@ -291,11 +290,16 @@
 
 			/* turn on the swap file */
 			if ((res = syscall(__NR_swapon, filename, 0)) != 0) {
-				tst_brkm(TFAIL | TERRNO, cleanup,
-					 "Failed swapon for file %s", filename);
-				/* must cleanup already swapon files */
-				clean_swap();
-				exit(1);
+				if (errno == EPERM) {
+					printf("Successfully created %d swapfiles\n", j);
+					break;
+				} else {
+					tst_brkm(TFAIL | TERRNO, cleanup,
+						 "Failed swapon for file %s", filename);
+					/* must cleanup already swapon files */
+					clean_swap();
+					exit(1);
+				}
 			}
 		}
 		tst_exit();

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#1 lore raw
Quoted 3 lines · Murlin Wenzel

This patch will allow swapon03 test case to pass even when max_swapfiles is not known.  Create maximum possible number of swapfiles during setup, then verify that attempting to create one more swapfile will return EPERM.  This is meant to change as little as possible of the existing code.

ACK.

This seems like a decent compromise because the point where this could fail is after the first iteration and we already check for root, which means that the first clause (CAP_SYS_ADMIN) of EPERM is caught:

EPERM
The caller does not have the CAP_SYS_ADMIN capability or the
maximal number of swap files has been reached. (The maximum is MAX_SWAPFILES-2(30) if CONFIG_MIGRATION is enabled, MAX_SWAPFILES (32) otherwise. In Linux kernel versions prior to 2.4.10, the maximum was always MAX_SWAPFILES, which was 8.

Thanks!
-Garrett

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw

PATCH 1/1 The sysctl system call will return EACCES error number on the new kernel

In reply to Murlin Wenzel

The sysctl system call will return EACCES error number on the new
kernel when
the user try to change the system parameter under
/proc/sys/kernel/ostype and
some other readonly parameters, but sysctl03 expected EPERM which
will cause
the test fail.

Thanks
Yingang

---
 testcases/kernel/syscalls/sysctl/sysctl03.c |   57 ++++++++++++++++++----------
 1 file changed, 37 insertions(+), 20 deletions(-)
testcases/kernel/syscalls/sysctl/sysctl03.c +37 -20
@@ -113,16 +113,25 @@ int main(int ac, char **av)
 			tst_resm(TFAIL, "sysctl(2) succeeded unexpectedly");
 		} else {
 			TEST_ERROR_LOG(TEST_ERRNO);
-
-			if (TEST_ERRNO != EPERM) {
-				tst_resm(TFAIL,
-					 "Expected EPERM (%d), got %d: %s",
-					 EPERM, TEST_ERRNO,
-					 strerror(TEST_ERRNO));
-			} else {
-				tst_resm(TPASS, "Got expected EPERM error");
+			if (tst_kvercmp(2,6,34)<0){
+				if (TEST_ERRNO != EPERM) {
+					tst_resm(TFAIL,
+							"Expected EPERM (%d), got %d: %s",
+							EPERM, TEST_ERRNO,
+							strerror(TEST_ERRNO));
+				} else {
+					tst_resm(TPASS, "Got expected EPERM error");
+				} else {
+					if (TEST_ERRNO != EACCES) {
+						tst_resm(TFAIL,
+								"Expected EACCES(%d), got %d: %s",
+								EACCES, TEST_ERRNO,
+								strerror(TEST_ERRNO));
+					} else {
+						tst_resm(TPASS, "Got expected EACCES error");
+					}
+				}
 			}
-		}
 
 		osnamelth = SIZE(osname);
 		if ((ltpuser = getpwnam("nobody")) == NULL) {
@@ -146,20 +155,28 @@ int main(int ac, char **av)
 				tst_resm(TFAIL, "call succeeded unexpectedly");
 			} else {
 				TEST_ERROR_LOG(TEST_ERRNO);
-
-				if (TEST_ERRNO != EPERM) {
-					tst_resm(TFAIL, "Expected EPERM, got "
-						 "%d", TEST_ERRNO);
-				} else {
-					tst_resm(TPASS, "Got expected EPERM "
-						 "error");
+				if (tst_kvercmp(2,6,34)<0){
+					if (TEST_ERRNO != EPERM) {
+						tst_resm(TFAIL, "Expected EPERM, got "
+								"%d", TEST_ERRNO);
+					} else {
+						tst_resm(TPASS, "Got expected EPERM "
+								"error");
+					} else{
+						if (TEST_ERRNO != EACCES) {
+							tst_resm(TFAIL, "Expected EACCES, got "
+									"%d", TEST_ERRNO);
+						} else {
+							tst_resm(TPASS, "Got expected EACCES"
+									"error");
+						}
+					}
 				}
-			}
 
-			cleanup();
+				cleanup();
 
-		} else {	/* parent */
-			/* wait for the child to finish */
+			} else {	/* parent */
+				/* wait for the child to finish */
 			wait(&status);
 		}
 

------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#3 lore raw

Re: [LTP] [Patch] The sysctl system call will return EACCES error number on the new kernel

Quoted 7 lines · Yingang

    The sysctl system call will return EACCES error number on the new kernel when
   the user try to change the system parameter under /proc/sys/kernel/ostype and
   some other readonly parameters, but sysctl03 expected EPERM which will cause
   the test fail.

There's some history behind this issue: http://lkml.org/lkml/2010/3/4/309 .

Given that documentation is probably not up to date for this yet, I'll just integrate the code that was provided (by Shi?) into the repository later on today or tomorrow. But the patch you provided doesn't make sense, even in terms of C code (you probably missed braces or something)...

Thanks,
-Garrett

------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list