* [LTP] [PATCH 2/3] Fix unshare01
@ 2009-08-24 4:05 CAI Qian
2009-08-24 5:38 ` Mike Frysinger
0 siblings, 1 reply; 2+ messages in thread
From: CAI Qian @ 2009-08-24 4:05 UTC (permalink / raw)
To: ltp-list
When no unshare function found during the build-time checking or the
kernel returns ENOSYS, it reports TCONF. It also simplify logic a little
bit and fix some coding style issues.
Signed-off-by: CAI Qian <caiqian@cclom.cn>
testcases/kernel/syscalls/unshare/unshare01.c | 105 ++++++++++++++++++-------
1 files changed, 78 insertions(+), 27 deletions(-)
diff --git a/testcases/kernel/syscalls/unshare/unshare01.c b/testcases/kernel/syscalls/unshare/unshare01.c
index 2a7cc1b..4ff58c5 100644
--- a/testcases/kernel/syscalls/unshare/unshare01.c
+++ b/testcases/kernel/syscalls/unshare/unshare01.c
@@ -92,7 +92,7 @@
/* Harness Specific Include Files. */
#include "test.h"
#include "usctest.h"
-#include "linux_syscall_numbers.h"
+#include "config.h"
/* Extern Global Variables */
extern int Tst_count; /* counter for tst_xxx routines. */
@@ -103,6 +103,9 @@ char *TCID = "unshare01"; /* Test program identifier.*/
int testno;
int TST_TOTAL =1; /* total number of tests in this file. */
+#ifdef HAVE_UNSHARE
+#include "linux_syscall_numbers.h"
+
/* Extern Global Functions */
/******************************************************************************/
/* */
@@ -177,47 +180,89 @@ int main(int ac, char **av) {
*fork a child process;testing which one is a child or a parent;
* */
TEST(pid1=fork()); //call to fork()
- if (TEST_RETURN == -1){
- tst_resm(TFAIL, "fork() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+ if (TEST_RETURN == -1) {
+ tst_resm(TFAIL, "fork() Failed, errno=%d : %s",
+ TEST_ERRNO, strerror(TEST_ERRNO));
cleanup();
tst_exit();
- }else if (TEST_RETURN == 0){
- if((TEST_RETURN = unshare(CLONE_FILES)) == 0) {
- tst_resm(TPASS, "unshare with CLONE_FILES call succeeded");
+ } else if (TEST_RETURN == 0) {
+ TEST_RETURN = unshare(CLONE_FS);
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS,
+ "unshare with CLONE_FILES call "
+ "succeeded");
+ else if (TEST_RETURN == -1) {
+ if (errno == ENOSYS)
+ tst_resm(TCONF,
+ "unshare is not "
+ "implemented in kernel."
+ );
+ else
+ tst_resm(TFAIL,
+ "unshare Failed, "
+ "errno=%d : %s",
+ errno,
+ strerror(errno));
+ }
tst_exit();
- }else if (TEST_RETURN == -1 )
- tst_resm(TFAIL,"unshare Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
- tst_exit();
}else{
}
TEST(pid1=fork()); //call to fork()
if (TEST_RETURN == -1){
- tst_resm(TFAIL, "fork() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+ tst_resm(TFAIL, "fork() Failed, errno=%d : %s",
+ TEST_ERRNO, strerror(TEST_ERRNO));
cleanup();
tst_exit();
- }else if (TEST_RETURN == 0){
- if((TEST_RETURN = unshare(CLONE_FS)) == 0) {
- tst_resm(TPASS, "unshare with CLONE_FS call succeeded");
- tst_exit();
- }else if (TEST_RETURN == -1 )
- tst_resm(TFAIL,"unshare Failed 2, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
- tst_exit();
+ } else if (TEST_RETURN == 0) {
+ TEST_RETURN = unshare(CLONE_FS);
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS,
+ "unshare with CLONE_FS call "
+ "succeeded");
+ else if (TEST_RETURN == -1) {
+ if (errno == ENOSYS)
+ tst_resm(TCONF,
+ "unshare is not "
+ "implemented in kernel."
+ );
+ else
+ tst_resm(TFAIL,
+ "unshare Failed 2, "
+ "errno=%d : %s",
+ errno,
+ strerror(errno));
+ }
+ tst_exit();
}else{
}
TEST(pid1=fork()); //call to fork()
- if (TEST_RETURN == -1){
- tst_resm(TFAIL, "fork() Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+ if (TEST_RETURN == -1) {
+ tst_resm(TFAIL, "fork() Failed, errno=%d : %s",
+ TEST_ERRNO, strerror(TEST_ERRNO));
cleanup();
tst_exit();
- }else if (TEST_RETURN == 0){
- if((TEST_RETURN = unshare(CLONE_NEWNS)) == 0) {
- tst_resm(TPASS, "unshare call with CLONE_NEWNS succeeded");
- tst_exit();
- }else if (TEST_RETURN == -1 )
- tst_resm(TFAIL,"unshare Failed 2, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
- tst_exit();
+ } else if (TEST_RETURN == 0) {
+ TEST_RETURN = unshare(CLONE_NEWNS);
+ if (TEST_RETURN == 0) {
+ tst_resm(TPASS,
+ "unshare call with CLONE_NEWNS "
+ "succeeded");
+ } else if (TEST_RETURN == -1) {
+ if (errno == ENOSYS)
+ tst_resm(TCONF,
+ "unshare is not "
+ "implemented in kernel."
+ );
+ else
+ tst_resm(TFAIL,
+ "unshare Failed 2, "
+ "errno=%d : %s",
+ errno,
+ strerror(errno));
+ }
+ tst_exit();
}else{
}
@@ -228,4 +273,10 @@ int main(int ac, char **av) {
cleanup();
tst_exit();
}
-
+#else
+int main(void)
+{
+ tst_resm(TCONF, "unshare is undefined.");
+ return 0;
+}
+#endif
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH 2/3] Fix unshare01
2009-08-24 4:05 [LTP] [PATCH 2/3] Fix unshare01 CAI Qian
@ 2009-08-24 5:38 ` Mike Frysinger
0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger @ 2009-08-24 5:38 UTC (permalink / raw)
To: ltp-list
[-- Attachment #1.1: Type: Text/Plain, Size: 615 bytes --]
On Monday 24 August 2009 00:05:59 CAI Qian wrote:
> +#ifdef HAVE_UNSHARE
> +#include "linux_syscall_numbers.h"
this doesnt make sense. if the C library has unshare(), then there is no
point in including the syscall numbers nor using syscall() because you can use
the C libraries' unshare().
> + tst_resm(TFAIL, "fork() Failed, errno=%d : %s",
> + TEST_ERRNO, strerror(TEST_ERRNO));
this (and just about every other line you changed) should be using the TTERRNO
flag rather than parsing TEST_ERRNO yourself. so this line would simply be:
tst_resm(TFAIL|TTERRNO, "fork() failed");
-mike
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 355 bytes --]
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
[-- Attachment #3: Type: text/plain, Size: 155 bytes --]
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-08-24 5:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-24 4:05 [LTP] [PATCH 2/3] Fix unshare01 CAI Qian
2009-08-24 5:38 ` Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox