* Check whether smackfs is set. * Use 'test.h' and 'tst_*'.
* Modify Makefile. * Delete 'message'. * Some cleanup. Signed-off-by: Zeng Linggang <zenglg...@cn.fujitsu.com> --- testcases/kernel/security/smack/Makefile | 2 +- .../security/smack/smack_set_socket_labels.c | 45 +++++++++++++--------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/testcases/kernel/security/smack/Makefile b/testcases/kernel/security/smack/Makefile index e114998..6d9abfd 100644 --- a/testcases/kernel/security/smack/Makefile +++ b/testcases/kernel/security/smack/Makefile @@ -8,7 +8,7 @@ top_srcdir ?= ../../../.. -include $(top_srcdir)/include/mk/env_pre.mk +include $(top_srcdir)/include/mk/testcases.mk INSTALL_TARGETS := *.sh diff --git a/testcases/kernel/security/smack/smack_set_socket_labels.c b/testcases/kernel/security/smack/smack_set_socket_labels.c index 086e4c8..df4a7a8 100644 --- a/testcases/kernel/security/smack/smack_set_socket_labels.c +++ b/testcases/kernel/security/smack/smack_set_socket_labels.c @@ -28,10 +28,16 @@ #endif #include <sys/xattr.h> +#include <sys/vfs.h> + +#include "test.h" +#include "usctest.h" + +char *TCID = "smack_set_socket_labels"; +int TST_TOTAL = 1; int main(int argc, char *argv[]) { - char message[256]; char *anin = "security.SMACK64IPIN"; char *anout = "security.SMACK64IPOUT"; char *annot = "security.SMACK64IPNOT"; @@ -40,35 +46,36 @@ int main(int argc, char *argv[]) char *avnot = "TheBadValue"; int sock; int rc; + char buf[256]; - if ((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { - sprintf(message, "%s Socket creation failure", argv[0]); - perror(message); - exit(1); - } + sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); + if (sock < 0) + tst_brkm(TFAIL, NULL, "%s Socket creation failure", argv[0]); + + flistxattr(sock, buf, 256); + if (strstr(buf, "security.SMACK64") == NULL) + tst_brkm(TCONF, NULL, "smackfs not set."); rc = fsetxattr(sock, anin, avin, strlen(avin) + 1, 0); if (rc < 0) { - sprintf(message, "%s fsetxattr of %s to %s failure", - argv[0], anin, avin); - perror(message); - exit(1); + tst_brkm(TFAIL, NULL, "%s fsetxattr of %s to %s failure", + argv[0], anin, avin); } rc = fsetxattr(sock, anout, avout, strlen(avout) + 1, 0); if (rc < 0) { - sprintf(message, "%s fsetxattr of %s to %s failure", - argv[0], anout, avout); - perror(message); - exit(1); + tst_brkm(TFAIL, NULL, "%s fsetxattr of %s to %s failure", + argv[0], anout, avout); } rc = fsetxattr(sock, annot, avnot, strlen(avnot) + 1, 0); if (rc >= 0) { - sprintf(message, "%s fsetxattr of %s to %s succeeded in error", - argv[0], anout, avout); - perror(message); - exit(1); + tst_brkm(TFAIL, NULL, + "%s fsetxattr of %s to %s succeeded in error", + argv[0], anout, avout); } - exit(0); + + tst_resm(TPASS, "Test %s success.", TCID); + + tst_exit(); } -- 1.9.3 ------------------------------------------------------------------------------ New Year. New Location. New Benefits. New Data Center in Ashburn, VA. GigeNET is offering a free month of service with a new server in Ashburn. Choose from 2 high performing configs, both with 100TB of bandwidth. Higher redundancy.Lower latency.Increased capacity.Completely compliant. http://p.sf.net/sfu/gigenet _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list