From: Garrett C. <su...@li...> - 2011-01-14 17:49:31
|
The branch, master, has been updated via c2ed6ed2fc21230a39d9c2052fd485314331fe0b (commit) via 2789bc7733942ff5d16005b65f9964d0fa6145e4 (commit) via 3ebf9b2141696535fbcdbefd6e275fbb9bfe1569 (commit) from bacc849720ec4efda5a0a8a9ea6a0e93a1415541 (commit) - Log ----------------------------------------------------------------- commit c2ed6ed2fc21230a39d9c2052fd485314331fe0b Author: Garrett Cooper <yan...@gm...> Date: Fri Jan 14 09:49:08 2011 -0800 Use safe macros. Signed-off-by: Garrett Cooper <yan...@gm...> commit 2789bc7733942ff5d16005b65f9964d0fa6145e4 Author: Garrett Cooper <yan...@gm...> Date: Fri Jan 14 09:45:16 2011 -0800 Fix testcase. Apparently this testcase peeks inside some structures that are only visible via malloc.h. Also simplify the testcase a bit. Reported-by: Peng Haitao <pe...@cn...> Acked-by: Cyril Hrubis <ch...@su...> Acked-by: Subrata Modak <su...@li...> Signed-off-by: Garrett Cooper <yan...@gm...> commit 3ebf9b2141696535fbcdbefd6e275fbb9bfe1569 Author: Garrett Cooper <yan...@gm...> Date: Fri Jan 14 09:44:12 2011 -0800 Fix header include. Reported-by: Peng Haitao <pe...@cn...> Acked-by: Cyril Hrubis <ch...@su...> Signed-off-by: Garrett Cooper <yan...@gm...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/mallopt/mallopt01.c | 79 +++++++++---------------- testcases/network/sockets/ltpServer.c | 2 +- 2 files changed, 28 insertions(+), 53 deletions(-) diff --git a/testcases/kernel/syscalls/mallopt/mallopt01.c b/testcases/kernel/syscalls/mallopt/mallopt01.c index d356cb2..9e60db7 100644 --- a/testcases/kernel/syscalls/mallopt/mallopt01.c +++ b/testcases/kernel/syscalls/mallopt/mallopt01.c @@ -33,16 +33,22 @@ * RESTRICTIONS */ -#include <stdio.h> /* needed by testhead.h */ #ifdef CONFIG_COLDFIRE #define __MALLOC_STANDARD__ #endif -#include <stdlib.h> #include <errno.h> +/* + * NOTE: struct mallinfo is only exported via malloc.h (not stdlib.h), even + * though it's an obsolete header for malloc(3). + * + * Inconsistencies rock. + */ +#include <malloc.h> +#include <stdio.h> -/***** LTP Port *****/ #include "test.h" #include "usctest.h" +#include "safe_macros.h" #define FAILED 0 #define PASSED 1 @@ -58,26 +64,15 @@ extern int Tst_COUNT; /* Test Case counter for tst_routines */ void printinfo(); #if !defined(UCLINUX) -/***** * * *****/ struct mallinfo info; -/*--------------------------------------------------------------*/ int main(int argc, char *argv[]) { char *buf; - int flag; - temp = stderr; tst_tmpdir(); -/*--------------------------------------------------------------*/ - local_flag = PASSED; - - flag = 0; - if ((buf = malloc(20480)) == NULL) { - tst_resm(TBROK, "Reason: Malloc failed! %s", strerror(errno)); - tst_exit(); - } + buf = SAFE_MALLOC(NULL, 20480); /* * Check space usage. @@ -85,18 +80,12 @@ int main(int argc, char *argv[]) info = mallinfo(); if (info.uordblks < 20480) { - fprintf(temp, "mallinfo failed: uordblks < 20K\n"); - flag = 1; - local_flag = FAILED; - }; - if (info.smblks != 0) { - fprintf(temp, "mallinfo failed: smblks != 0\n"); - flag = 1; - local_flag = FAILED; + printinfo(); + tst_resm(TFAIL, "mallinfo failed: uordblks < 20K"); } - if (flag == 1) { + if (info.smblks != 0) { printinfo(); - flag = 0; + tst_resm(TFAIL, "mallinfo failed: smblks != 0"); } free(buf); @@ -105,48 +94,34 @@ int main(int argc, char *argv[]) */ mallopt(M_MXFAST, 2048); mallopt(M_NLBLKS, 50); - if ((buf = malloc(1024)) == NULL) { - tst_resm(TBROK, "Reason:Malloc failed. %s", strerror(errno)); - tst_exit(); - } + buf = SAFE_MALLOC(NULL, 1024); free(buf); - (local_flag == PASSED) ? tst_resm(TPASS, - "Test passed") : tst_resm(TFAIL, - "Test failed"); -/*--------------------------------------------------------------*/ -/* Clean up any files created by test before call to anyfail. */ - unlink("core"); tst_rmdir(); - tst_exit(); /* THIS CALL DOES NOT RETURN - EXITS!! */ tst_exit(); } -/*--------------------------------------------------------------*/ void printinfo() { - fprintf(temp, "mallinfo structure:\n"); - fprintf(temp, "mallinfo.arena = %d\n", info.arena); - fprintf(temp, "mallinfo.ordblks = %d\n", info.ordblks); - fprintf(temp, "mallinfo.smblks = %d\n", info.smblks); - fprintf(temp, "mallinfo.hblkhd = %d\n", info.hblkhd); - fprintf(temp, "mallinfo.hblks = %d\n", info.hblks); - fprintf(temp, "mallinfo.usmblks = %d\n", info.usmblks); - fprintf(temp, "mallinfo.fsmblks = %d\n", info.fsmblks); - fprintf(temp, "mallinfo.uordblks = %d\n", info.uordblks); - fprintf(temp, "mallinfo.fordblks = %d\n", info.fordblks); - fprintf(temp, "mallinfo.keepcost = %d\n", info.keepcost); + fprintf(stderr, "mallinfo structure:\n"); + fprintf(stderr, "mallinfo.arena = %d\n", info.arena); + fprintf(stderr, "mallinfo.ordblks = %d\n", info.ordblks); + fprintf(stderr, "mallinfo.smblks = %d\n", info.smblks); + fprintf(stderr, "mallinfo.hblkhd = %d\n", info.hblkhd); + fprintf(stderr, "mallinfo.hblks = %d\n", info.hblks); + fprintf(stderr, "mallinfo.usmblks = %d\n", info.usmblks); + fprintf(stderr, "mallinfo.fsmblks = %d\n", info.fsmblks); + fprintf(stderr, "mallinfo.uordblks = %d\n", info.uordblks); + fprintf(stderr, "mallinfo.fordblks = %d\n", info.fordblks); + fprintf(stderr, "mallinfo.keepcost = %d\n", info.keepcost); } #else - int main() { - tst_resm(TINFO, "test is not available on uClinux"); - tst_exit(); + tst_brkm(TCONF, NULL, "test is not available on uClinux"); } - #endif /* if !defined(UCLINUX) */ diff --git a/testcases/network/sockets/ltpServer.c b/testcases/network/sockets/ltpServer.c index 94eabf1..5e41b88 100644 --- a/testcases/network/sockets/ltpServer.c +++ b/testcases/network/sockets/ltpServer.c @@ -28,10 +28,10 @@ * */ #include <sys/types.h> +#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> -#include <socket.h> #include <stdio.h> #include <stdlib.h> #include <string.h> hooks/post-receive -- ltp |