public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP
@ 2009-05-27 10:06 Manas Kumar Nayak
  2009-05-27 10:07 ` [LTP] [PATCH 01/13] Add/Port Utility Headers for these set of tests Manas Kumar Nayak
                   ` (13 more replies)
  0 siblings, 14 replies; 31+ messages in thread
From: Manas Kumar Nayak @ 2009-05-27 10:06 UTC (permalink / raw)
  To: LTP List; +Cc: Manas Kumar Nayak

Hi,

>On Tue, 2009-05-19 at 00:39 +0530, Manas Kumar Nayak wrote:
>Hi,
> 
> I have ported the following tests from Crackerjack to LTP.
> Kindly include them to LTP:
> 
> [PATCH 01/21] Add add_key01 test for add_key syscall
> [PATCH 02/21] Add add_key02 test for add_key syscall
> [PATCH 03/21] Add bdflush01 test for bdflush syscall
> [PATCH 04/21] Add exit_group01 test for exit_group syscall
> [PATCH 05/21] Add keyctl01 test for keyctl syscall
> [PATCH 06/21] Add newuname01 test for newuname syscall
> [PATCH 07/21] Add rt_sigaction01 test for rt_sigaction syscall
> [PATCH 08/21] Add rt_sigprocmask01 test for rt_sigprocmask syscall
> [PATCH 09/21] Add rt_sigprocmask02 test for rt_sigprocmask syscall
> [PATCH 10/21] Add rt_sigqueueinfo01 test for rt_sigqueueinfo syscall
> [PATCH 11/21] Add rt_sigsuspend01 test for rt_sigsuspend syscall
> [PATCH 12/21] Add set_thread_area01 test for set_thread_area syscall
> [PATCH 13/21] Add set_thread_area02 test for set_thread_area syscall
> [PATCH 14/21] Add set_tid_address01 test for set_tid_address syscall
> [PATCH 15/21] Add sgetmask01 test for sgetmask syscall
> [PATCH 16/21] Add sigreturn01 test for sigreturn syscall
> [PATCH 17/21] Add ssetmask01 test for ssetmask syscall
> [PATCH 18/21] Add timer_getoverrun01 test for timer_getoverrun01 syscall
> [PATCH 19/21] Add timer_gettime01 test for timer_gettime syscall
> [PATCH 20/21] Add tkill01 test for tkill syscall
> [PATCH 21/21] Add tkill02 test for tkill syscall
> 
> Todo:
> 	1) Port the Remaining ones (next week),

As promised earlier, here remains the 2nd Bunch of tests ported
from Crackerjack to LTP:

__001_Add_Utility_Headers_for_these_set_of_tests.patch
__002_Add_get_mempolicy01_test_for_get_mempolicy_syscall.patch
__003_Add_clock_getres01_test_for_clock_getres_syscall.patch
__004_Add_clock_nanosleep01_test_for_clock_nanosleep_syscall.patch
__005_Add_mq_notify01_test_for_mq_notify_syscall.patch
__006_Add_ppoll01_test_for_ppoll_syscall.patch
__007_Add_mq_open01_test_for_mq_open_syscall.patch
__008_Add_mq_timedreceive01_test_for_mq_timedreceive_syscall.patch
__009_Add_utimes01_test_for_utimes_syscall.patch
__010_Add_mq_unlink01_test_for_mq_unlink_syscall.patch
__011_Add_mq_timedsend01_test_for_mq_timedsend_syscall.patch
__012_Add_unshare01_test_for_unshare_syscall.patch
__013_Add_unshare02_test_for_unshare_syscall.patch

Still TODO:
-> The remaining testcases will be ported soon.

Regards--
Manas

> 
> Regards--
> Manas
> 

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [LTP] [PATCH 01/13] Add/Port Utility Headers for these set of tests
  2009-05-27 10:06 [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Manas Kumar Nayak
@ 2009-05-27 10:07 ` Manas Kumar Nayak
  2009-05-29 12:55   ` Subrata Modak
  2009-05-27 10:07 ` [LTP] [PATCH 02/13] Add/Port get_mempolicy01 test for get_mempolicy() syscall Manas Kumar Nayak
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 31+ messages in thread
From: Manas Kumar Nayak @ 2009-05-27 10:07 UTC (permalink / raw)
  To: LTP List; +Cc: Manas Kumar Nayak

Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>
To: LTP List <ltp-list@lists.sourceforge.net>
Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
Cc: Masatake YAMATO <yamato@redhat.com>
---

--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/utils/common_j_h.c	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/utils/common_j_h.c	2009-05-18 21:35:36.000000000 +0530
@@ -0,0 +1,360 @@
+/*
+ * Crackerjack Project
+ *
+ * Copyright (C) 2007-2008, Hitachi, Ltd.
+ * Author(s): Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
+ *            Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * $Id:$
+ *
+ */
+//#define _GNU_SOURCE 1
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <mqueue.h>
+#include "include_j_h.h"
+
+
+/*
+ * Change user ID
+ *
+ *   We assume 'test' executable is executed with 'root' permission.
+ *   So, if you use this function, you can not return 'root' uid.
+ */
+int setup_uid(char *uname)
+{
+	struct passwd *pw;
+	int rc;
+
+	pw = getpwnam(uname);
+	if (!pw) {
+		EPRINTF("getpwnam failed.\n");
+		return -1;
+	}
+	rc = setuid(pw->pw_uid);
+	if (rc < 0) {
+		EPRINTF("setuid failed.\n");
+		return -1;
+	}
+	return 0;
+}
+
+/*
+ * Change effective user ID
+ */
+int setup_euid(char *uname, uid_t *old_uid)
+{
+	struct passwd *pw;
+	int rc;
+
+	*old_uid = geteuid();
+	pw = getpwnam(uname);
+	if (!pw) {
+		EPRINTF("getpwnam failed.\n");
+		return -1;
+	}
+	rc = seteuid(pw->pw_uid);
+	if (rc < 0) {
+		EPRINTF("seteuid failed.\n");
+		return -1;
+	}
+	return 0;
+}
+
+int cleanup_euid(uid_t old_uid)
+{
+	int rc;
+
+	rc = seteuid(old_uid);
+	if (rc < 0) {
+		EPRINTF("seteuid failed.\n");
+		return -1;
+	}
+	return 0;
+}
+
+
+/*
+ * Generate a child process which will send a signal
+ */
+static void sighandler_for_sig_proc(int sig)
+{
+	if (sig == SIGUSR2)
+		return;
+	return;
+}
+
+pid_t create_sig_proc(unsigned long usec, int sig)
+{
+	pid_t pid, cpid;
+
+	signal(SIGUSR2, sighandler_for_sig_proc);
+	pid = getpid();
+	cpid = fork();
+	switch (cpid) {
+	case 0:
+		pause();
+		usleep(usec);
+		kill(pid, sig);
+		_exit(0);
+		break;
+	case -1:
+		EPRINTF("fork failed.\n");
+		return cpid;
+	default:
+		kill(cpid, SIGUSR2);
+		return cpid;
+	}
+}
+
+
+/*
+ * Create and delete test file
+ */
+int setup_file(char *testdir, char *fname, char *path)
+{
+	return _setup_file(testdir, fname, path,
+			   O_CREAT|O_EXCL|O_RDWR, S_IRUSR|S_IWUSR);
+}
+
+int _setup_file(char *testdir, char *fname, char *path, int flags, mode_t mode)
+{
+	int rc;
+
+	sprintf(path, "%s/%s", testdir, fname);
+	rc = open(path, flags, mode);
+	if (rc < 0) {
+		EPRINTF("open failed.\n");
+		return -1;
+	}
+	return rc;
+}
+
+int cleanup_file(char *path)
+{
+	unlink(path);
+	return 0;
+}
+
+
+/*
+ * Create and delete swap file
+ */
+/* swap file needs to be more than 40KB */
+#define MIN_SWAPFILE_SIZE	(64 * 1024)
+int setup_swapfile(char *testdir, char *fname, char *path, size_t size)
+{
+	int fd = -1, rc;
+	size_t r_sz;
+	int cmdlen = 256;
+	char cmd[cmdlen];
+	char *p = NULL;
+
+	sprintf(path, "%s/%s", testdir, fname);
+	fd = open(path, O_CREAT|O_EXCL|O_RDWR, S_IRUSR|S_IWUSR);
+	if (fd < 0) {
+		EPRINTF("open failed.\n");
+		goto ERR_EXIT;
+	}
+	if (size < MIN_SWAPFILE_SIZE) {
+		EPRINTF("size too short.\n");
+		goto ERR_EXIT;
+	}
+	p = malloc(size);
+	if (!p) {
+		EPRINTF("malloc failed.\n");
+		goto ERR_EXIT;
+	}
+	/* Swap file must not have hole area */
+	memset(p, 0x5a, size);
+	r_sz = (size_t)write(fd, p, size);
+	if (r_sz != size) {
+		EPRINTF("write failed.\n");
+		goto ERR_EXIT;
+	}
+	snprintf(cmd, cmdlen, "/sbin/mkswap %s > /dev/null 2>&1", path);
+	rc = system(cmd);
+	if (rc != 0) {
+		EPRINTF("system(%s) failed.\n", cmd);
+		goto ERR_EXIT;
+	}
+	return fd;
+
+ERR_EXIT:
+	if (fd >= 0)
+		close(fd);
+	if (p)
+		free(p);
+	return -1;
+}
+
+int cleanup_swapfile(char *path)
+{
+	unlink(path);
+	return 0;
+}
+
+
+/*
+ * Change user limit that the calling process can open
+ */
+int setup_ulimit_fnum(rlim_t newlim, rlim_t *oldlim)
+{
+	int rc;
+	struct rlimit rlim;
+
+	rc = getrlimit(RLIMIT_NOFILE, &rlim);
+	if (rc < 0) {
+		EPRINTF("getrlimit failed.\n");
+		return -1;
+	}
+	*oldlim = rlim.rlim_cur;
+	if (newlim > rlim.rlim_max) {
+		EPRINTF("can't set ulimit value: %ld.\n", newlim);
+		return -1;
+	}
+	rlim.rlim_cur = newlim;
+	rc = setrlimit(RLIMIT_NOFILE, &rlim);
+	if (rc < 0) {
+		EPRINTF("setrlimit failed.\n");
+		return -1;
+	}
+	return 0;
+}
+
+int cleanup_ulimit_fnum(rlim_t oldlim)
+{
+	int rc;
+	struct rlimit rlim;
+
+	rc = getrlimit(RLIMIT_NOFILE, &rlim);
+	if (rc < 0) {
+		EPRINTF("getrlimit failed.\n");
+		return -1;
+	}
+	if (oldlim > rlim.rlim_max) {
+		EPRINTF("can't set ulimit value: %ld.\n", oldlim);
+		return -1;
+	}
+	rlim.rlim_cur = oldlim;
+	rc = setrlimit(RLIMIT_NOFILE, &rlim);
+	if (rc < 0) {
+		EPRINTF("setrlimit failed.\n");
+		return -1;
+	}
+	return 0;
+}
+
+
+/*
+ * Change /proc or /sys setting
+ */
+int setup_proc_fs(char *path, int newval, int *oldval)
+{
+	int fd = -1, rc, len;
+	char buf[32];
+
+	fd = open(path, O_RDWR);
+	if (fd < 0) {
+		EPRINTF("open %s failed.\n", path);
+		return -1;
+	}
+
+	do {
+		rc = read(fd, buf, 32);
+	} while (rc < 0 && errno == EAGAIN);
+	if (rc < 0) {
+		EPRINTF("read failed.\n");
+		return -1;
+	}
+
+	*oldval = atoi(buf);
+	sprintf(buf, "%d\n", newval);
+	len = strlen(buf);
+	rc = write(fd, buf, len);
+	if (rc != len) {
+		EPRINTF("write failed.\n");
+		return -1;
+	}
+	return 0;
+}
+
+int cleanup_proc_fs(char *path, int oldval)
+{
+	int fd = -1, rc, len;
+	char buf[32];
+
+	fd = open(path, O_RDWR);
+	if (fd < 0) {
+		EPRINTF("open %s failed.\n", path);
+		return -1;
+	}
+
+	sprintf(buf, "%d\n", oldval);
+	len = strlen(buf);
+	rc = write(fd, buf, len);
+	if (rc != len) {
+		EPRINTF("write failed.\n");
+		return -1;
+	}
+	return 0;
+}
+
+
+#if 0
+/*
+ * Check max nodes from /sys/devices/system/node/node* files (for NUMA)
+ */
+int get_max_nodes(void)
+{
+	/* We assume that there is only one node */
+	return 1;
+}
+#endif
+
+/*
+ * Get unexist pid
+ */
+pid_t get_unexist_pid(void)
+{
+	pid_t pid;
+	int st;
+
+	pid = fork();
+	switch (pid) {
+	case -1:
+		EPRINTF("fork failed.\n");
+		return -1;
+	case 0:
+		_exit(0);
+	default:
+		wait(&st);
+		return pid;
+	}
+}
+
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/utils/include_j_h.h	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/utils/include_j_h.h	2009-05-18 21:35:36.000000000 +0530
@@ -0,0 +1,160 @@
+/*
+ * Crackerjack Project
+ *
+ * Copyright (C) 2007-2008, Hitachi, Ltd.
+ * Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,
+ *            Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
+ *            Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * $Id:$
+ *
+ */
+#ifndef __CJK_SYSCALL_J_H__
+#define __CJK_SYSCALL_J_H__
+
+#include <sys/time.h>
+#include <sys/resource.h>
+
+
+#define REG_RESULT_LOG_FP	stdout
+#define REG_DETAIL_LOG_FP	stderr
+
+
+/*
+ * RPRINTF : macro to output test result
+ */
+#define RPRINTF(...)						\
+	do {							\
+		fprintf(REG_RESULT_LOG_FP, __VA_ARGS__);	\
+	} while (0)
+
+
+/*
+ * PRINTF : macro to output detail log
+ */
+#define PRINTF(...)						\
+	do {							\
+		fprintf(REG_DETAIL_LOG_FP, __VA_ARGS__);	\
+	} while (0)
+
+
+/*
+ * EPRINTF : macro to output error message
+ */
+#define EPRINTF(...)						\
+	do {							\
+		fprintf(REG_DETAIL_LOG_FP, __VA_ARGS__);	\
+	} while (0)
+
+
+/*
+ * DPRINTF : macro to output debug message
+ */
+#define DPRINTF(...)						\
+	do {							\
+		if (opt_debug)					\
+			PRINTF("[DEBUG] " __VA_ARGS__);		\
+	} while (0)
+
+
+/*
+ * PRINT_XXX : macro to output test result and expect
+ */
+#define __PRINT_EXPECT(rc_has_range, rc, errno)				\
+	do {								\
+		if (rc_has_range)					\
+			PRINTF("EXPECT: return value(ret)=%s",		\
+			       (rc) >= 0 ? "(N >= 0)" : "(N <  0)");	\
+		else							\
+			PRINTF("EXPECT: return value(ret)=%d", rc);	\
+		PRINTF(" errno=%d (%s)", errno, strerror(errno));	\
+	} while (0)
+
+#define __PRINT_RESULT(rc_has_range, rc, errno)				\
+	do {								\
+		if (rc_has_range)					\
+			PRINTF("RESULT: return value(ret)=%8d", rc);	\
+		else							\
+			PRINTF("RESULT: return value(ret)=%d", rc);	\
+		PRINTF(" errno=%d (%s)", errno, strerror(errno));	\
+	} while (0)
+
+#define PRINT_RESULT(rc_has_range, e_rc, e_errno, r_rc, r_errno)	\
+	do {								\
+		__PRINT_EXPECT(rc_has_range, e_rc, e_errno);		\
+		PRINTF("\n");						\
+		__PRINT_RESULT(rc_has_range, r_rc, r_errno);		\
+		PRINTF("\n");						\
+	} while (0)
+
+#define PRINT_RESULT_EXTRA(rc_has_range, e_rc, e_errno, r_rc, r_errno,	\
+			   str, extra_ok)				\
+	do {								\
+		__PRINT_EXPECT(rc_has_range, e_rc, e_errno);		\
+		if ((extra_ok))						\
+			PRINTF("\n");					\
+		else							\
+			PRINTF(", %s=OK\n", str);			\
+		__PRINT_RESULT(rc_has_range, r_rc, r_errno);		\
+		if ((extra_ok))						\
+			PRINTF("\n");					\
+		else							\
+			PRINTF(", %s=NG\n", str);			\
+	} while (0)
+
+#define PRINT_RESULT_CMP(rc_has_range, e_rc, e_errno, r_rc, r_errno, cmp_ok) \
+	PRINT_RESULT_EXTRA(rc_has_range, e_rc, e_errno, r_rc, r_errno,	\
+			   "r/w check", cmp_ok)
+
+
+/*
+ * Definitions
+ */
+enum result_val {
+	RESULT_OK,
+	RESULT_NG
+};
+
+
+/*
+ * Prototype
+ */
+int setup_uid(char *uname);
+int setup_euid(char *uname, uid_t *old_uid);
+int cleanup_euid(uid_t old_uid);
+
+pid_t create_sig_proc(unsigned long usec, int sig);
+
+int _setup_file(char *testdir, char *fname, char *path, int flags, mode_t mode);
+int setup_file(char *testdir, char *fname, char *path);
+int cleanup_file(char *path);
+
+int setup_swapfile(char *testdir, char *fname, char *path, size_t size);
+int cleanup_swapfile(char *path);
+
+int setup_ulimit_fnum(rlim_t newlim, rlim_t *oldlim);
+int cleanup_ulimit_fnum(rlim_t oldlim);
+
+int setup_proc_fs(char *path, int newval, int *oldval);
+int cleanup_proc_fs(char *path, int oldval);
+
+#define QUEUE_NAME	"/test_mqueue"
+pid_t create_echo_msg_proc(void);
+
+pid_t get_unexist_pid(void);
+
+#endif /* __CJK_SYSCALL_J_H__ */
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/utils/inotify.h	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/utils/inotify.h	2009-05-18 21:35:36.000000000 +0530
@@ -0,0 +1,227 @@
+/*
+ * Inode based directory notification for Linux
+ *
+ * Copyright (C) 2005 John McCutchan
+ */
+
+#ifndef _LINUX_INOTIFY_H
+#define _LINUX_INOTIFY_H
+
+#include <linux/types.h>
+
+/*
+ * struct inotify_event - structure read from the inotify device for each event
+ *
+ * When you are watching a directory, you will receive the filename for events
+ * such as IN_CREATE, IN_DELETE, IN_OPEN, IN_CLOSE, ..., relative to the wd.
+ */
+struct inotify_event {
+	__s32		wd;		/* watch descriptor */
+	__u32		mask;		/* watch mask */
+	__u32		cookie;		/* cookie to synchronize two events */
+	__u32		len;		/* length (including nulls) of name */
+	char		name[0];	/* stub for possible name */
+};
+
+/* the following are legal, implemented events that user-space can watch for */
+#define IN_ACCESS		0x00000001	/* File was accessed */
+#define IN_MODIFY		0x00000002	/* File was modified */
+#define IN_ATTRIB		0x00000004	/* Metadata changed */
+#define IN_CLOSE_WRITE		0x00000008	/* Writtable file was closed */
+#define IN_CLOSE_NOWRITE	0x00000010	/* Unwrittable file closed */
+#define IN_OPEN			0x00000020	/* File was opened */
+#define IN_MOVED_FROM		0x00000040	/* File was moved from X */
+#define IN_MOVED_TO		0x00000080	/* File was moved to Y */
+#define IN_CREATE		0x00000100	/* Subfile was created */
+#define IN_DELETE		0x00000200	/* Subfile was deleted */
+#define IN_DELETE_SELF		0x00000400	/* Self was deleted */
+#define IN_MOVE_SELF		0x00000800	/* Self was moved */
+
+/* the following are legal events.  they are sent as needed to any watch */
+#define IN_UNMOUNT		0x00002000	/* Backing fs was unmounted */
+#define IN_Q_OVERFLOW		0x00004000	/* Event queued overflowed */
+#define IN_IGNORED		0x00008000	/* File was ignored */
+
+/* helper events */
+#define IN_CLOSE		(IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* close */
+#define IN_MOVE			(IN_MOVED_FROM | IN_MOVED_TO) /* moves */
+
+/* special flags */
+#define IN_ONLYDIR		0x01000000	/* only watch the path if it is a directory */
+#define IN_DONT_FOLLOW		0x02000000	/* don't follow a sym link */
+#define IN_MASK_ADD		0x20000000	/* add to the mask of an already existing watch */
+#define IN_ISDIR		0x40000000	/* event occurred against dir */
+#define IN_ONESHOT		0x80000000	/* only send event once */
+
+/*
+ * All of the events - we build the list by hand so that we can add flags in
+ * the future and not break backward compatibility.  Apps will get only the
+ * events that they originally wanted.  Be sure to add new events here!
+ */
+#define IN_ALL_EVENTS	(IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \
+			 IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \
+			 IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \
+			 IN_MOVE_SELF)
+
+#ifdef __KERNEL__
+
+#include <linux/dcache.h>
+#include <linux/fs.h>
+
+/*
+ * struct inotify_watch - represents a watch request on a specific inode
+ *
+ * h_list is protected by ih->mutex of the associated inotify_handle.
+ * i_list, mask are protected by inode->inotify_mutex of the associated inode.
+ * ih, inode, and wd are never written to once the watch is created.
+ *
+ * Callers must use the established inotify interfaces to access inotify_watch
+ * contents.  The content of this structure is private to the inotify
+ * implementation.
+ */
+struct inotify_watch {
+	struct list_head	h_list;	/* entry in inotify_handle's list */
+	struct list_head	i_list;	/* entry in inode's list */
+	atomic_t		count;	/* reference count */
+	struct inotify_handle	*ih;	/* associated inotify handle */
+	struct inode		*inode;	/* associated inode */
+	__s32			wd;	/* watch descriptor */
+	__u32			mask;	/* event mask for this watch */
+};
+
+struct inotify_operations {
+	void (*handle_event)(struct inotify_watch *, u32, u32, u32,
+			     const char *, struct inode *);
+	void (*destroy_watch)(struct inotify_watch *);
+};
+
+#ifdef CONFIG_INOTIFY
+
+/* Kernel API for producing events */
+
+extern void inotify_d_instantiate(struct dentry *, struct inode *);
+extern void inotify_d_move(struct dentry *);
+extern void inotify_inode_queue_event(struct inode *, __u32, __u32,
+				      const char *, struct inode *);
+extern void inotify_dentry_parent_queue_event(struct dentry *, __u32, __u32,
+					      const char *);
+extern void inotify_unmount_inodes(struct list_head *);
+extern void inotify_inode_is_dead(struct inode *);
+extern u32 inotify_get_cookie(void);
+
+/* Kernel Consumer API */
+
+extern struct inotify_handle *inotify_init(const struct inotify_operations *);
+extern void inotify_init_watch(struct inotify_watch *);
+extern void inotify_destroy(struct inotify_handle *);
+extern __s32 inotify_find_watch(struct inotify_handle *, struct inode *,
+				struct inotify_watch **);
+extern __s32 inotify_find_update_watch(struct inotify_handle *, struct inode *,
+				       u32);
+extern __s32 inotify_add_watch(struct inotify_handle *, struct inotify_watch *,
+			       struct inode *, __u32);
+extern int inotify_rm_watch(struct inotify_handle *, struct inotify_watch *);
+extern int inotify_rm_wd(struct inotify_handle *, __u32);
+extern void inotify_remove_watch_locked(struct inotify_handle *,
+					struct inotify_watch *);
+extern void get_inotify_watch(struct inotify_watch *);
+extern void put_inotify_watch(struct inotify_watch *);
+
+#else
+
+static inline void inotify_d_instantiate(struct dentry *dentry,
+					struct inode *inode)
+{
+}
+
+static inline void inotify_d_move(struct dentry *dentry)
+{
+}
+
+static inline void inotify_inode_queue_event(struct inode *inode,
+					     __u32 mask, __u32 cookie,
+					     const char *filename,
+					     struct inode *n_inode)
+{
+}
+
+static inline void inotify_dentry_parent_queue_event(struct dentry *dentry,
+						     __u32 mask, __u32 cookie,
+						     const char *filename)
+{
+}
+
+static inline void inotify_unmount_inodes(struct list_head *list)
+{
+}
+
+static inline void inotify_inode_is_dead(struct inode *inode)
+{
+}
+
+static inline u32 inotify_get_cookie(void)
+{
+	return 0;
+}
+
+static inline struct inotify_handle *inotify_init(const struct inotify_operations *ops)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
+static inline void inotify_init_watch(struct inotify_watch *watch)
+{
+}
+
+static inline void inotify_destroy(struct inotify_handle *ih)
+{
+}
+
+static inline __s32 inotify_find_watch(struct inotify_handle *ih, struct inode *inode,
+				       struct inotify_watch **watchp)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline __s32 inotify_find_update_watch(struct inotify_handle *ih,
+					      struct inode *inode, u32 mask)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline __s32 inotify_add_watch(struct inotify_handle *ih,
+				      struct inotify_watch *watch,
+				      struct inode *inode, __u32 mask)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline int inotify_rm_watch(struct inotify_handle *ih,
+				   struct inotify_watch *watch)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline int inotify_rm_wd(struct inotify_handle *ih, __u32 wd)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline void inotify_remove_watch_locked(struct inotify_handle *ih,
+					       struct inotify_watch *watch)
+{
+}
+
+static inline void get_inotify_watch(struct inotify_watch *watch)
+{
+}
+
+static inline void put_inotify_watch(struct inotify_watch *watch)
+{
+}
+
+#endif	/* CONFIG_INOTIFY */
+
+#endif	/* __KERNEL __ */
+
+#endif	/* _LINUX_INOTIFY_H */
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/utils/ioprio.h	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/utils/ioprio.h	2009-05-18 21:35:36.000000000 +0530
@@ -0,0 +1,46 @@
+#ifndef __IOPRIO_H__
+#define	__IOPRIO_H__
+
+//----------------------------------------------------------------------------
+// Copy of the 2.6.18 kernel header (linux/ioprio.h)
+//
+
+/*
+ * Gives us 8 prio classes with 13-bits of data for each class
+ */
+#define IOPRIO_BITS		(16)
+#define IOPRIO_CLASS_SHIFT	(13)
+#define IOPRIO_PRIO_MASK	((1UL << IOPRIO_CLASS_SHIFT) - 1)
+
+#define IOPRIO_PRIO_CLASS(mask)	((mask) >> IOPRIO_CLASS_SHIFT)
+#define IOPRIO_PRIO_DATA(mask)	((mask) & IOPRIO_PRIO_MASK)
+#define IOPRIO_PRIO_VALUE(class, data)	(((class) << IOPRIO_CLASS_SHIFT) | data)
+
+#define ioprio_valid(mask)	(IOPRIO_PRIO_CLASS((mask)) != IOPRIO_CLASS_NONE)
+
+/*
+ * These are the io priority groups as implemented by CFQ. RT is the realtime
+ * class, it always gets premium service. BE is the best-effort scheduling
+ * class, the default for any process. IDLE is the idle scheduling class, it
+ * is only served when no one else is using the disk.
+ */
+enum {
+	IOPRIO_CLASS_NONE,
+	IOPRIO_CLASS_RT,
+	IOPRIO_CLASS_BE,
+	IOPRIO_CLASS_IDLE,
+};
+
+/*
+ * 8 best effort priority levels are supported
+ */
+#define IOPRIO_BE_NR	(8)
+
+enum {
+	IOPRIO_WHO_PROCESS = 1,
+	IOPRIO_WHO_PGRP,
+	IOPRIO_WHO_USER,
+};
+//-----------------------------------------------------------------------------
+
+#endif /* __IOPRIO_H__ */
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/utils/numaif.h	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/utils/numaif.h	2009-05-18 21:35:36.000000000 +0530
@@ -0,0 +1,115 @@
+/*
+ * Crackerjack Project
+ *
+ * Copyright (C) 2007-2008, Hitachi, Ltd.
+ * Author(s): Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
+ *            Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>
+ *
+ *            Derived from 'numa.h' in numactl-0.9.8
+ *            Copyright (C) 2003,2004 Andi Kleen, SuSE Labs.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * $Id:$
+ *
+ */
+
+#include "./include_j_h.h"
+
+#ifndef __NR_mbind
+#  define __NR_mbind			274
+#endif
+#ifndef __NR_get_mempolicy
+#  define __NR_get_mempolicy		275
+#endif
+#ifndef __NR_set_mempolicy
+#  define __NR_set_mempolicy		276
+#endif
+#ifndef __NR_migrate_pages
+#  define __NR_migrate_pages		294
+#endif
+#ifndef __NR_move_pages
+#  define __NR_move_pages		317
+#endif
+
+
+
+
+#define NUMA_NUM_NODES 	128
+typedef struct { 
+	unsigned long n[NUMA_NUM_NODES/(sizeof(unsigned long)*8)];
+} nodemask_t;
+
+static inline void nodemask_zero(nodemask_t *mask)
+{ 
+	memset(mask->n, 0, sizeof(mask->n)); 
+} 
+
+static inline void nodemask_set(nodemask_t *mask, int node)
+{
+	mask->n[node / (8*sizeof(unsigned long))] |=
+		(1UL << (node % (8*sizeof(unsigned long))));		
+} 
+
+static inline void nodemask_clr(nodemask_t *mask, int node)
+{
+	mask->n[node / (8*sizeof(unsigned long))] &= 
+		~(1UL << (node % (8*sizeof(unsigned long))));	
+}
+
+static inline int nodemask_isset(const nodemask_t *mask, int node)
+{
+	if ((unsigned)node >= NUMA_NUM_NODES)
+		return 0;
+	if (mask->n[node / (8*sizeof(unsigned long))] & 
+		(1UL << (node % (8*sizeof(unsigned long)))))
+		return 1;
+	return 0;	
+}
+
+static inline int nodemask_equal(const nodemask_t *a, const nodemask_t *b) 
+{ 
+	int i;
+	for (i = 0; i < NUMA_NUM_NODES/(sizeof(unsigned long)*8); i++) 
+		if (a->n[i] != b->n[i]) 
+			return 0; 
+	return 1;
+} 
+
+static inline void nodemask_dump(const char *header, const nodemask_t *mask)
+{
+	int i;
+	EPRINTF("%s", header);
+	for (i = 0; i < NUMA_NUM_NODES/(sizeof(unsigned long)*8); i++) 
+		EPRINTF(" 0x%08lx", mask->n[i]);
+	EPRINTF("\n");
+}
+
+
+#ifndef MPOL_DEFAULT
+   // Policies
+#  define MPOL_DEFAULT			0
+#  define MPOL_PREFERRED		1
+#  define MPOL_BIND			2
+#  define MPOL_INTERLEAVE		3
+   // Flags for get_mem_policy
+#  define MPOL_F_NODE			(1<<0)
+#  define MPOL_F_ADDR			(1<<1)
+   // Flags for mbind
+#  define MPOL_MF_STRICT		(1<<0)
+#  define MPOL_MF_MOVE			(1<<1)
+#  define MPOL_MF_MOVE_ALL		(1<<2)
+#endif
+
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/utils/poll.h	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/utils/poll.h	2009-05-18 21:35:36.000000000 +0530
@@ -0,0 +1,27 @@
+#ifndef __i386_POLL_H
+#define __i386_POLL_H
+
+/* These are specified by iBCS2 */
+#define POLLIN		0x0001
+#define POLLPRI		0x0002
+#define POLLOUT		0x0004
+#define POLLERR		0x0008
+#define POLLHUP		0x0010
+#define POLLNVAL	0x0020
+
+/* The rest seem to be more-or-less nonstandard. Check them! */
+#define POLLRDNORM	0x0040
+#define POLLRDBAND	0x0080
+#define POLLWRNORM	0x0100
+#define POLLWRBAND	0x0200
+#define POLLMSG		0x0400
+#define POLLREMOVE	0x1000
+#define POLLRDHUP       0x2000
+
+struct pollfd {
+	int fd;
+	short events;
+	short revents;
+};
+
+#endif

---
Regards--
Manas


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [LTP] [PATCH 02/13] Add/Port get_mempolicy01 test for get_mempolicy() syscall
  2009-05-27 10:06 [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Manas Kumar Nayak
  2009-05-27 10:07 ` [LTP] [PATCH 01/13] Add/Port Utility Headers for these set of tests Manas Kumar Nayak
@ 2009-05-27 10:07 ` Manas Kumar Nayak
  2009-05-29 12:55   ` Subrata Modak
  2009-05-27 10:08 ` [LTP] [PATCH 03/13] Add/Port clock_getres01 test for clock_getres() syscall Manas Kumar Nayak
                   ` (11 subsequent siblings)
  13 siblings, 1 reply; 31+ messages in thread
From: Manas Kumar Nayak @ 2009-05-27 10:07 UTC (permalink / raw)
  To: LTP List; +Cc: Manas Kumar Nayak

Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>
To: LTP List <ltp-list@lists.sourceforge.net>
Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
Cc: Masatake YAMATO <yamato@redhat.com>
---

--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c	2009-05-26 21:32:56.000000000 +0530
@@ -0,0 +1,453 @@
+/******************************************************************************/
+/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
+/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
+/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
+/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
+/*                                                                  	      */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
+/*                                                                            */
+/******************************************************************************/
+/******************************************************************************/
+/*                                                                            */
+/* File:        get_mempolicy01.c                                             */
+/*                                                                            */
+/* Description: This tests the get_mempolicy() syscall                        */
+/*									      */
+/* 									      */
+/*									      */
+/*									      */
+/*									      */
+/*                                                                            */
+/* Usage:  <for command-line>                                                 */
+/* get_mempolicy01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                        */
+/*      where,  -c n : Run n copies concurrently.                             */
+/*              -e   : Turn on errno logging.                                 */
+/*              -i n : Execute test n times.                                  */
+/*              -I x : Execute test for x seconds.                            */
+/*              -P x : Pause for x seconds between iterations.                */
+/*              -t   : Turn on syscall timing.                                */
+/*                                                                            */
+/* Total Tests: 1                                                             */
+/*                                                                            */
+/* Test Name:   get_mempolicy01                                             */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
+/******************************************************************************/
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <getopt.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include "../utils/numaif.h"
+#include "../utils/include_j_h.h"
+#include "../utils/common_j_h.c"
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+#include "linux_syscall_numbers.h"
+
+/* Extern Global Variables */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "get_mempolicy01";  /* Test program identifier.*/
+int  testno;
+int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
+
+/* Extern Global Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    cleanup                                                       */
+/*                                                                            */
+/* Description: Performs all one time clean up for this test on successful    */
+/*              completion,  premature exit or  failure. Closes all temporary */
+/*              files, removes all temporary directories exits the test with  */
+/*              appropriate return code by calling tst_exit() function.       */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
+/*              On success - Exits calling tst_exit(). With '0' return code.  */
+/*                                                                            */
+/******************************************************************************/
+extern void cleanup() {
+        /* Remove tmp dir and all files in it */
+        TEST_CLEANUP;
+        tst_rmdir();
+
+        /* Exit with appropriate return code. */
+        tst_exit();
+}
+
+/* Local  Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    setup                                                         */
+/*                                                                            */
+/* Description: Performs all one time setup for this test. This function is   */
+/*              typically used to capture signals, create temporary dirs      */
+/*              and temporary files that may be used in the course of this    */
+/*              test.                                                         */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits by calling cleanup().                      */
+/*              On success - returns 0.                                       */
+/*                                                                            */
+/******************************************************************************/
+void setup() {
+        /* Capture signals if any */
+        /* Create temporary directories */
+        TEST_PAUSE;
+        tst_tmpdir();
+}
+
+
+/*
+ * Macros
+ */
+#define SYSCALL_NAME    "get_mempolicy"
+
+
+/*
+ * Global variables
+ */
+static int opt_debug;
+static char *progname;
+
+enum test_type {
+        DEFAULT,        // get default policy
+        ADDR,           // get policy of memory which include mapped address
+        INVALID_POINTER,
+        INVALID_FLAGS,
+};
+
+enum from_node {
+        NONE,
+        SELF,
+};
+
+
+/*
+ * Data Structure
+ */
+struct test_case {
+        int ttype;
+        int policy;
+        int from_node;
+        int ret;
+        int err;
+};
+
+/* Test cases
+ *
+ *   test status of errors on man page
+ *
+ *   (NONE)             man page hadn't been completed.
+ *
+ *   test status of errors NOT on man page
+ *
+ *   EFAULT             v (invalid address)
+ *   EINVAL             v (invalid parameters)
+ */
+
+static struct test_case tcase[] = {
+        { // case00
+                .ttype          = DEFAULT,
+                .policy         = MPOL_DEFAULT,
+                .from_node      = NONE,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case01
+                .ttype          = DEFAULT,
+                .policy         = MPOL_BIND,
+                .from_node      = SELF,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case02
+                .ttype          = DEFAULT,
+                .policy         = MPOL_INTERLEAVE,
+                .from_node      = SELF,
+                .ret            = 0,
+                .err            = 0,
+        },
+{ // case03
+                .ttype          = DEFAULT,
+                .policy         = MPOL_PREFERRED,
+                .from_node      = NONE,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case04
+                .ttype          = DEFAULT,
+                .policy         = MPOL_PREFERRED,
+                .from_node      = SELF,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case05
+                .ttype          = ADDR,
+                .policy         = MPOL_DEFAULT,
+                .from_node      = NONE,
+                .ret            = 0,
+                .err            = 0,
+        },
+{ // case06
+                .ttype          = ADDR,
+                .policy         = MPOL_BIND,
+                .from_node      = SELF,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case07
+                .ttype          = ADDR,
+                .policy         = MPOL_INTERLEAVE,
+                .from_node      = SELF,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case08
+                .ttype          = ADDR,
+                .policy         = MPOL_PREFERRED,
+                .from_node      = NONE,
+                .ret            = 0,
+                .err            = 0,
+        },
+{ // case09
+                .ttype          = ADDR,
+                .policy         = MPOL_PREFERRED,
+                .from_node      = SELF,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case10
+                .ttype          = INVALID_POINTER,
+                .policy         = MPOL_DEFAULT,
+                .from_node      = NONE,
+                .ret            = -1,
+                .err            = EFAULT,
+        },
+        { // case11
+                .ttype          = INVALID_FLAGS,
+                .policy         = MPOL_DEFAULT,
+                .from_node      = NONE,
+                .ret            = -1,
+                .err            = EINVAL,
+        },
+};
+
+#define MEM_LENGTH              (4 * 1024 * 1024)
+/*
+ * do_test()
+ *
+ *   Input  : TestCase Data
+ *   Return : RESULT_OK(0), RESULT_NG(1)
+ *
+ */
+
+static int do_test(struct test_case *tc)
+{
+        int sys_ret;
+        int sys_errno;
+        int result = RESULT_OK;
+        int rc, policy, flags, cmp_ok = 1;
+        nodemask_t nodemask, getnodemask;
+        unsigned long maxnode = NUMA_NUM_NODES;
+        char *p = NULL;
+        unsigned long len = MEM_LENGTH;
+
+        /* We assume that there is only one node(node0). */
+        nodemask_zero(&nodemask);
+        nodemask_set(&nodemask, 0);
+        nodemask_zero(&getnodemask);
+
+        switch (tc->ttype) {
+        case DEFAULT:
+                flags = 0;
+                p = NULL;
+                // set memory policy
+                if (tc->from_node == NONE)
+                        TEST(rc = syscall(__NR_set_mempolicy, tc->policy, NULL, 0));
+                else
+                        TEST(rc = syscall(__NR_set_mempolicy, tc->policy,&nodemask, maxnode));
+
+		if (TEST_RETURN < 0) {
+			tst_resm(TFAIL, "set_mempolicy() failed - errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        result = 1;
+			cleanup();
+                        tst_exit();
+                }
+                break;
+        default:
+                flags = MPOL_F_ADDR;
+                // mmap memory
+                p = mmap(NULL, len, PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+                if (p == (void*)-1) {
+			tst_resm(TFAIL, "malloc failed - errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        result = 1;
+			cleanup();
+                        tst_exit();
+                }
+                // set memory policy
+                if (tc->from_node == NONE)
+                        TEST(rc = syscall(__NR_mbind, p, len, tc->policy,NULL, 0, 0));
+                else
+                        TEST(rc = syscall(__NR_mbind, p, len, tc->policy,&nodemask, maxnode, 0));
+                if (tc->ttype == INVALID_POINTER)
+                        p = NULL;
+
+		if (tc->ttype == INVALID_FLAGS){
+                        flags = -1;
+                	break;
+        	}
+	}
+        /*
+         * Execute system call
+         */
+        errno = 0;
+        TEST(sys_ret = syscall(__NR_get_mempolicy, &policy, &getnodemask, maxnode,p, flags));
+        sys_errno = errno;
+        if (sys_ret < 0)
+                goto TEST_END;
+
+        // When policy equals MPOL_DEFAULT, then get_mempolicy not return node
+        if (tc->policy == MPOL_DEFAULT)
+                nodemask_zero(&nodemask);
+        cmp_ok = tc->policy == policy && nodemask_equal(&nodemask,&getnodemask);
+        if (opt_debug) {
+                nodemask_dump("nodemask Expect:", &nodemask);
+                nodemask_dump("nodemask Result:", &getnodemask);
+                tst_resm(TINFO,"policy E:%d R:%d", tc->policy, policy);
+        }
+TEST_END:
+        /*
+         * Check results
+         */
+        result |= (sys_errno != tc->err) || !cmp_ok;
+        PRINT_RESULT_CMP(0, tc->ret, tc->err, sys_ret, sys_errno, cmp_ok);
+EXIT:
+        return result;
+}
+
+
+/*
+ * usage()
+ */
+
+void usage(const char *progname)
+{
+        tst_resm(TINFO,"usage: %s [options]", progname);
+        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
+        tst_resm(TINFO,"options:");
+        tst_resm(TINFO,"    -d --debug           Show debug messages");
+        tst_resm(TINFO,"    -h --help            Show this message");
+
+        tst_resm(TINFO,"NG");
+        exit(1);
+}
+
+
+/*
+ * main()
+ */
+
+
+
+int main(int ac, char **av) {
+	int result = RESULT_OK;
+        int c;
+        int i;
+        int lc;                 /* loop counter */
+        char *msg;              /* message returned from parse_opts */
+
+	struct option long_options[] = {
+                { "debug", no_argument, 0, 'd' },
+                { "help",  no_argument, 0, 'h' },
+                { NULL, 0, NULL, 0 }
+        };
+
+	progname = strchr(av[0], '/');
+        progname = progname ? progname + 1 : av[0];	
+	
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
+
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
+			 while(TEST_RETURN != -1) {
+		                switch (c) {
+                		case 'd':
+		                        opt_debug = 1;
+                		        break;
+		                default:
+                		        usage(progname);
+                        		// NOTREACHED
+                		}
+		        }
+
+		/*
+		* Execute test
+         	*/
+	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
+        	        int ret;
+	                tst_resm(TINFO,"(case%02d) START", i);
+	                ret = do_test(&tcase[i]);
+	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
+	                result |= ret;
+        	}
+		
+		/*
+        	 * Check results
+         	*/
+        	switch(result) {
+	        case RESULT_OK:
+        			tst_resm(TPASS, "get_mempolicy call succeeded");
+		                break;
+
+	        default:
+                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
+        		        tst_resm(TINFO,"NG");
+				cleanup();
+				tst_exit();
+		                break;
+        	}
+	
+	     }
+
+          }
+        cleanup();
+	tst_exit();
+}
+
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/get_mempolicy/Makefile	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/get_mempolicy/Makefile	2009-05-22 23:56:55.000000000 +0530
@@ -0,0 +1,31 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2009
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+CFLAGS += -I../../../../include -Wall -O2
+LDLIBS += -L../../../../lib -lltp 
+
+SRCS    = $(wildcard *.c)
+TARGETS = $(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+
+clean:
+	rm -f $(TARGETS)
--- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-26 21:12:52.000000000 +0530
+++ ltp-intermediate-20090521/runtest/syscalls	2009-05-26 21:34:34.000000000 +0530
@@ -393,6 +393,7 @@ getresuid03 getresuid03
 getrlimit01 getrlimit01
 getrlimit02 getrlimit02
 
+get_mempolicy01 get_mempolicy01
 get_robust_list01 get_robust_list01
 
 getrusage01 getrusage01

---
Regards--
Manas


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [LTP] [PATCH 03/13] Add/Port clock_getres01 test for clock_getres() syscall
  2009-05-27 10:06 [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Manas Kumar Nayak
  2009-05-27 10:07 ` [LTP] [PATCH 01/13] Add/Port Utility Headers for these set of tests Manas Kumar Nayak
  2009-05-27 10:07 ` [LTP] [PATCH 02/13] Add/Port get_mempolicy01 test for get_mempolicy() syscall Manas Kumar Nayak
@ 2009-05-27 10:08 ` Manas Kumar Nayak
  2009-05-29 12:56   ` Subrata Modak
  2009-05-27 10:08 ` [LTP] [PATCH 04/13] Add/Port clock_nanosleep01 test for clock_nanosleep() syscall Manas Kumar Nayak
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 31+ messages in thread
From: Manas Kumar Nayak @ 2009-05-27 10:08 UTC (permalink / raw)
  To: LTP List; +Cc: Manas Kumar Nayak

Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>
To: LTP List <ltp-list@lists.sourceforge.net>
Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
Cc: Masatake YAMATO <yamato@redhat.com>
---

--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/clock_getres/clock_getres01.c	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/clock_getres/clock_getres01.c	2009-05-27 12:15:45.000000000 +0530
@@ -0,0 +1,344 @@
+/******************************************************************************/
+/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
+/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
+/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
+/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
+/*                                                                  	      */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
+/*                                                                            */
+/******************************************************************************/
+/******************************************************************************/
+/*                                                                            */
+/* File:        clock_getres01.c                                              */
+/*                                                                            */
+/* Description: This tests the clock_getres() syscall                         */
+/*									      */
+/* 									      */
+/*									      */
+/*									      */
+/*									      */
+/*                                                                            */
+/* Usage:  <for command-line>                                                 */
+/* clock_getres01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                        */
+/*      where,  -c n : Run n copies concurrently.                             */
+/*              -e   : Turn on errno logging.                                 */
+/*              -i n : Execute test n times.                                  */
+/*              -I x : Execute test for x seconds.                            */
+/*              -P x : Pause for x seconds between iterations.                */
+/*              -t   : Turn on syscall timing.                                */
+/*                                                                            */
+/* Total Tests: 1                                                             */
+/*                                                                            */
+/* Test Name:   clock_getres01                                                */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
+/******************************************************************************/
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <getopt.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
+#include <time.h>
+
+
+#include "../utils/include_j_h.h"
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+#include "linux_syscall_numbers.h"
+
+/* Extern Global Variables */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "clock_getres01";  /* Test program identifier.*/
+int  testno;
+int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
+
+/* Extern Global Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    cleanup                                                       */
+/*                                                                            */
+/* Description: Performs all one time clean up for this test on successful    */
+/*              completion,  premature exit or  failure. Closes all temporary */
+/*              files, removes all temporary directories exits the test with  */
+/*              appropriate return code by calling tst_exit() function.       */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
+/*              On success - Exits calling tst_exit(). With '0' return code.  */
+/*                                                                            */
+/******************************************************************************/
+extern void cleanup() {
+        /* Remove tmp dir and all files in it */
+        TEST_CLEANUP;
+        tst_rmdir();
+
+        /* Exit with appropriate return code. */
+        tst_exit();
+}
+
+/* Local  Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    setup                                                         */
+/*                                                                            */
+/* Description: Performs all one time setup for this test. This function is   */
+/*              typically used to capture signals, create temporary dirs      */
+/*              and temporary files that may be used in the course of this    */
+/*              test.                                                         */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits by calling cleanup().                      */
+/*              On success - returns 0.                                       */
+/*                                                                            */
+/******************************************************************************/
+void setup() {
+        /* Capture signals if any */
+        /* Create temporary directories */
+        TEST_PAUSE;
+        tst_tmpdir();
+}
+
+
+/*
+ * Macros
+ */
+#define SYSCALL_NAME    "clock_getres"
+
+
+/*
+ * Global variables
+ */
+static int opt_debug;
+static char *progname;
+
+enum test_type {
+		NORMAL,
+		NULL_POINTER,
+};
+
+
+/*
+ * Data Structure
+ */
+struct test_case {
+	clockid_t clk_id;
+        int ttype;
+        int ret;
+        int err;
+};
+
+
+/* Test cases
+*
+*   test status of errors on man page
+*
+*   EPERM   can't check because clock_getres not requires permission
+*   EINVAL  v (not supported clk_id)
+*/
+
+static struct test_case tcase[] = {
+        { // case00
+                .clk_id         = CLOCK_REALTIME,
+                .ttype          = NORMAL,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case01
+                .clk_id         = CLOCK_MONOTONIC,
+                .ttype          = NORMAL,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case02
+                .clk_id         = CLOCK_PROCESS_CPUTIME_ID,
+                .ttype          = NORMAL,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case03
+                .clk_id         = CLOCK_THREAD_CPUTIME_ID,
+                .ttype          = NORMAL,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case04
+                .clk_id         = -1,
+                .ttype          = NORMAL,
+                .ret            = -1,
+                .err            = EINVAL,
+        },
+        { // case05
+                .clk_id         = CLOCK_REALTIME,
+                .ttype          = NULL_POINTER,
+                .ret            = 0,
+                .err            = 0,
+        },
+};
+
+
+
+
+#define MEM_LENGTH              (4 * 1024 * 1024)
+/*
+ * do_test()
+ *
+ *   Input  : TestCase Data
+ *   Return : RESULT_OK(0), RESULT_NG(1)
+ *
+ */
+
+static int do_test(struct test_case *tc)
+{
+        int sys_ret;
+        int sys_errno;
+        int result = RESULT_OK;
+	struct timespec res;
+
+	/*
+         * Execute system call
+         */
+        errno = 0;
+        if (tc->ttype == NULL_POINTER)
+                TEST(sys_ret = clock_getres(tc->clk_id, NULL));
+        else
+                TEST(sys_ret = clock_getres(tc->clk_id, &res));
+        sys_errno = errno;
+
+        /*
+         * Check results
+         */
+        result |= (sys_errno != tc->err);
+        PRINT_RESULT(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno);
+
+        return result;
+}
+
+
+/*
+ * usage()
+ */
+
+static void usage(const char *progname)
+{
+        tst_resm(TINFO,"usage: %s [options]", progname);
+        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
+        tst_resm(TINFO,"options:");
+        tst_resm(TINFO,"    -d --debug           Show debug messages");
+        tst_resm(TINFO,"    -h --help            Show this message");
+
+        tst_resm(TINFO,"NG");
+        exit(1);
+}
+
+
+/*
+ * main()
+ */
+
+
+
+int main(int ac, char **av) {
+	int result = RESULT_OK;
+        int c;
+        int i;
+        int lc;                 /* loop counter */
+        char *msg;              /* message returned from parse_opts */
+
+	struct option long_options[] = {
+                { "debug", no_argument, 0, 'd' },
+                { "help",  no_argument, 0, 'h' },
+                { NULL, 0, NULL, 0 }
+        };
+
+	progname = strchr(av[0], '/');
+        progname = progname ? progname + 1 : av[0];	
+	
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
+
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
+			 while(TEST_RETURN != -1) {
+		                switch (c) {
+                		case 'd':
+		                        opt_debug = 1;
+                		        break;
+		                default:
+                		        usage(progname);
+                        		// NOTREACHED
+                		}
+		        }
+
+
+		if (ac != optind) {
+        	        tst_resm(TINFO,"Options are not match.");
+                	usage(progname);
+                	// NOTREACHED
+	        }
+
+		/*
+		* Execute test
+         	*/
+	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
+        	        int ret;
+	                tst_resm(TINFO,"(case%02d) START", i);
+	                ret = do_test(&tcase[i]);
+	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
+	                result |= ret;
+        	}
+		
+		/*
+        	 * Check results
+         	*/
+        	switch(result) {
+	        case RESULT_OK:
+        			tst_resm(TPASS, "clock_getres call succeeded");
+		                break;
+
+	        default:
+                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
+        		        RPRINTF("NG\n");
+				cleanup();
+				tst_exit();
+		                break;
+        	}
+
+                }
+        }	
+        cleanup();
+	tst_exit();
+}
+
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/clock_getres/Makefile	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/clock_getres/Makefile	2009-05-22 23:43:27.000000000 +0530
@@ -0,0 +1,31 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2009
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+CFLAGS += -I../../../../include -Wall -O2
+LDLIBS += -L../../../../lib -lltp -lrt
+
+SRCS    = $(wildcard *.c)
+TARGETS = $(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+
+clean:
+	rm -f $(TARGETS)
--- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 12:11:54.000000000 +0530
+++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 12:18:36.000000000 +0530
@@ -74,6 +74,7 @@ chroot02 chroot02
 chroot03 chroot03
 chroot04 chroot04
 
+clock_getres01 clock_getres01
 clock_nanosleep2_01 clock_nanosleep2_01
 
 clone01 clone01

---
Regards--
Manas


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [LTP] [PATCH 04/13] Add/Port clock_nanosleep01 test for clock_nanosleep() syscall
  2009-05-27 10:06 [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Manas Kumar Nayak
                   ` (2 preceding siblings ...)
  2009-05-27 10:08 ` [LTP] [PATCH 03/13] Add/Port clock_getres01 test for clock_getres() syscall Manas Kumar Nayak
@ 2009-05-27 10:08 ` Manas Kumar Nayak
  2009-05-29 12:56   ` Subrata Modak
  2009-05-27 10:09 ` [LTP] [PATCH 05/13] Add/Port mq_notify01 test for mq_notify() syscall Manas Kumar Nayak
                   ` (9 subsequent siblings)
  13 siblings, 1 reply; 31+ messages in thread
From: Manas Kumar Nayak @ 2009-05-27 10:08 UTC (permalink / raw)
  To: LTP List; +Cc: Manas Kumar Nayak

Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>
To: LTP List <ltp-list@lists.sourceforge.net>
Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
Cc: Masatake YAMATO <yamato@redhat.com>
---

--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c	2009-05-27 12:29:23.000000000 +0530
@@ -0,0 +1,470 @@
+/******************************************************************************/
+/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
+/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
+/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
+/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
+/*                                                                  	      */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
+/*                                                                            */
+/******************************************************************************/
+/******************************************************************************/
+/*                                                                            */
+/* File:        clock_nanosleep01.c                                           */
+/*                                                                            */
+/* Description: This tests the clock_nanosleep() syscall                      */
+/*									      */
+/* 									      */
+/*									      */
+/*									      */
+/*									      */
+/*                                                                            */
+/* Usage:  <for command-line>                                                 */
+/* clock_nanosleep01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                     */
+/*      where,  -c n : Run n copies concurrently.                             */
+/*              -e   : Turn on errno logging.                                 */
+/*              -i n : Execute test n times.                                  */
+/*              -I x : Execute test for x seconds.                            */
+/*              -P x : Pause for x seconds between iterations.                */
+/*              -t   : Turn on syscall timing.                                */
+/*                                                                            */
+/* Total Tests: 1                                                             */
+/*                                                                            */
+/* Test Name:   clock_nanosleep01                                             */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
+/******************************************************************************/
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <getopt.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
+#include <time.h>
+#include <signal.h>
+#include "../utils/common_j_h.c"
+#include "../utils/include_j_h.h"
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+#include "linux_syscall_numbers.h"
+
+/* Extern Global Variables */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "clock_nanosleep01";  /* Test program identifier.*/
+int  testno;
+int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
+
+/* Extern Global Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    cleanup                                                       */
+/*                                                                            */
+/* Description: Performs all one time clean up for this test on successful    */
+/*              completion,  premature exit or  failure. Closes all temporary */
+/*              files, removes all temporary directories exits the test with  */
+/*              appropriate return code by calling tst_exit() function.       */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
+/*              On success - Exits calling tst_exit(). With '0' return code.  */
+/*                                                                            */
+/******************************************************************************/
+extern void cleanup() {
+        /* Remove tmp dir and all files in it */
+        TEST_CLEANUP;
+        tst_rmdir();
+
+        /* Exit with appropriate return code. */
+        tst_exit();
+}
+
+/* Local  Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    setup                                                         */
+/*                                                                            */
+/* Description: Performs all one time setup for this test. This function is   */
+/*              typically used to capture signals, create temporary dirs      */
+/*              and temporary files that may be used in the course of this    */
+/*              test.                                                         */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits by calling cleanup().                      */
+/*              On success - returns 0.                                       */
+/*                                                                            */
+/******************************************************************************/
+void setup() {
+        /* Capture signals if any */
+        /* Create temporary directories */
+        TEST_PAUSE;
+        tst_tmpdir();
+}
+
+
+/*
+ * Macros
+ */
+#define SYSCALL_NAME    "clock_nanosleep"
+
+
+/*
+ * Global variables
+ */
+static int opt_debug;
+static char *progname;
+
+enum test_type {
+		NORMAL,
+		NULL_POINTER,
+		SEND_SIGINT,
+};
+
+
+/*
+ * Data Structure
+ */
+struct test_case {
+	clockid_t clk_id;
+	int ttype;
+        int flags;
+        time_t sec;
+        long nsec;
+	int ret;
+        int err;
+};
+
+
+/* Test cases
+ *
+ *   test status of errors on man page
+ *
+ *   EINTR              v (function was interrupted by a signal)
+ *   EINVAL             v (invalid tv_nsec, etc.)
+ *   ENOTSUP            can't check because not supported clk_id generates
+ *                      EINVAL
+ */
+
+
+static struct test_case tcase[] = {
+        { // case00
+                .clk_id         = CLOCK_REALTIME,
+                .ttype          = NORMAL,
+		.flags          = 0,
+                .sec            = 0,
+                .nsec           = 500000000, // 500msec
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case01
+                .clk_id         = CLOCK_MONOTONIC,
+                .ttype          = NORMAL,
+		.flags          = 0,
+                .sec            = 0,
+                .nsec           = 500000000, // 500msec
+                .ret            = 0,
+                .err            = 0,
+        },
+	{ // case02
+                .ttype          = NORMAL,
+                .clk_id         = CLOCK_REALTIME,
+                .flags          = 0,
+                .sec            = 0,
+                .nsec           = -1,   // invalid
+                .ret            = EINVAL,
+                .err            = 0,
+        },
+        { // case03
+                .ttype          = NORMAL,
+                .clk_id         = CLOCK_REALTIME,
+                .flags          = 0,
+                .sec            = 0,
+                .nsec           = 1000000000,   // invalid
+                .ret            = EINVAL,
+                .err            = 0,
+        },
+        { // case04
+                .ttype          = NORMAL,
+                .clk_id         = CLOCK_THREAD_CPUTIME_ID, // not supported
+                .flags          = 0,
+                .sec            = 0,
+                .nsec           = 500000000, // 500msec
+                .ret            = ENOTSUP, // RHEL4U1 + 2.6.18 returns EINVAL
+                .err            = 0,
+        },
+        { // case05
+                .ttype          = SEND_SIGINT,
+                .clk_id         = CLOCK_REALTIME,
+                .flags          = 0,
+                .sec            = 10,
+                .nsec           = 0,
+                .ret            = EINTR,
+                .err            = 0,
+        },
+#if 0   // glibc generates SEGV error (RHEL4U1 + 2.6.18)
+        { // caseXX
+                .ttype          = NULL_POINTER,
+                .clk_id         = CLOCK_REALTIME,
+                .flags          = 0,
+                .sec            = 0,
+                .nsec           = 500000000, // 500msec
+                .ret            = EFAULT,
+                .err            = 0,
+        },
+#endif
+};
+
+
+/*
+ * chk_difftime()
+ *   Return : OK(0), NG(-1)
+ */
+#define MAX_MSEC_DIFF   20
+
+static int chk_difftime(struct timespec *bef, struct timespec *aft,
+                        time_t sec, long nsec)
+{
+        struct timespec t;
+        time_t expect;
+        time_t result;
+
+        t.tv_sec = aft->tv_sec - bef->tv_sec;
+        t.tv_nsec = aft->tv_nsec - bef->tv_nsec;
+        if (t.tv_nsec < 0) {
+                t.tv_sec -= 1;
+                t.tv_nsec += 1000000000;
+        }
+        TEST(expect = (sec * 1000) + (nsec / 1000000));
+        TEST(result = (t.tv_sec * 1000) + (t.tv_nsec / 1000000));
+        tst_resm(TINFO,"check sleep time: (min:%ld) < %ld < (max:%ld) (msec)",expect - MAX_MSEC_DIFF, result, expect + MAX_MSEC_DIFF);
+        if (result < expect - MAX_MSEC_DIFF || result > expect + MAX_MSEC_DIFF)
+                return -1;
+	return 0;
+}
+
+
+/*
+ * do_test()
+ *
+ *   Input  : TestCase Data
+ *   Return : RESULT_OK(0), RESULT_NG(1)
+ *
+ */
+static int do_test(struct test_case *tc)
+{
+        int sys_ret;
+        int sys_errno;
+        int result = RESULT_OK;
+        struct timespec beftp, afttp, rq, rm;
+        int rc, range_ok = 1, remain_ok = 1;
+        pid_t pid = 0;
+
+	 /*
+         * Check before sleep time
+         */
+        if (tc->ttype == SEND_SIGINT) {
+                TEST(pid = create_sig_proc(500000, SIGINT));
+                if (TEST_RETURN < 0)
+                        return 1;
+        }
+
+        /*
+         * Check before sleep time
+         */
+        TEST(rc = clock_gettime(tc->clk_id, &beftp));
+        if (rc < 0) {
+                tst_resm(TFAIL, "iclock_gettime failed - errno = %d : %s", TEST_ERRNO, strerror(TEST_ERRNO));
+                result = 1;
+                goto EXIT;
+        }
+	 /*
+         * Execute system call
+         */
+        rq.tv_sec = tc->sec;
+        rq.tv_nsec = tc->nsec;
+        // !!!CAUTION: 'clock_gettime' returns errno itself
+        errno = 0;
+        if (tc->ttype == NULL_POINTER)
+                TEST(sys_ret = clock_nanosleep(tc->clk_id, tc->flags, NULL, &rm));
+        else
+                TEST(sys_ret = clock_nanosleep(tc->clk_id, tc->flags, &rq, &rm));
+        sys_errno = errno;
+        if (sys_ret != 0)
+                goto TEST_END;
+	
+	 /*
+         * Check after sleep time
+         */
+        TEST(rc = clock_gettime(tc->clk_id, &afttp));
+        if (TEST_RETURN < 0) {
+                EPRINTF("clock_gettime failed.\n");
+                result = 1;
+                goto EXIT;
+        }
+	range_ok = chk_difftime(&beftp, &afttp, tc->sec, tc->nsec) == 0;
+	/*
+         * Check remaining time
+         */
+TEST_END:
+        if (tc->ttype == NORMAL || tc->ttype == SEND_SIGINT) {
+                tst_resm(TINFO,"remain time: %ld %ld", rm.tv_sec, rm.tv_nsec);
+                if (tc->ttype == NORMAL)
+                        remain_ok = rm.tv_sec == 0 && rm.tv_nsec == 0;
+                else
+                        remain_ok = rm.tv_sec != 0 || rm.tv_nsec != 0;
+        }
+
+	/*
+         * Check results
+         */
+        result |= (sys_ret != tc->ret) || !range_ok || !remain_ok;
+        if (!range_ok)
+                PRINT_RESULT_EXTRA(0, tc->ret, tc->err, sys_ret, sys_errno,"time range check", range_ok);
+        else
+                PRINT_RESULT_EXTRA(0, tc->ret, tc->err, sys_ret, sys_errno,"remain time check", remain_ok);
+EXIT:
+        if (pid > 0) {
+                int st;
+                TEST(kill(pid, SIGTERM));
+                TEST(wait(&st));
+        }
+        return result;
+}
+
+/*
+ * sighandler()
+ */
+void sighandler(int sig)
+{
+        if (sig == SIGINT)
+                return;
+        // NOTREACHED
+        return;
+}
+
+
+/*
+ * usage()
+ */
+
+static void usage(const char *progname)
+{
+        tst_resm(TINFO,"usage: %s [options]", progname);
+        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
+        tst_resm(TINFO,"options:");
+        tst_resm(TINFO,"    -d --debug           Show debug messages");
+        tst_resm(TINFO,"    -h --help            Show this message");
+        tst_resm(TINFO,"NG");
+        exit(1);
+}
+
+
+/*
+ * main()
+ */
+
+
+
+int main(int ac, char **av) {
+	int result = RESULT_OK;
+        int c;
+        int i;
+        int lc;                 /* loop counter */
+        char *msg;              /* message returned from parse_opts */
+
+	struct option long_options[] = {
+                { "debug", no_argument, 0, 'd' },
+                { "help",  no_argument, 0, 'h' },
+                { NULL, 0, NULL, 0 }
+        };
+
+	progname = strchr(av[0], '/');
+        progname = progname ? progname + 1 : av[0];	
+	
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
+
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
+			 while(TEST_RETURN != -1) {
+		                switch (c) {
+                		case 'd':
+		                        opt_debug = 1;
+                		        break;
+		                default:
+                		        usage(progname);
+                        		// NOTREACHED
+                		}
+		        }
+
+
+		if (ac != optind) {
+        	        tst_resm(TINFO,"Options are not match.");
+                	usage(progname);
+                	// NOTREACHED
+	        }
+
+		/*
+		* Execute test
+         	*/
+		TEST(signal(SIGINT, sighandler));
+	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
+        	        int ret;
+	                tst_resm(TINFO,"(case%02d) START", i);
+	                ret = do_test(&tcase[i]);
+	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
+	                result |= ret;
+        	}
+		
+		/*
+        	 * Check results
+         	*/
+        	switch(result) {
+	        case RESULT_OK:
+        			tst_resm(TPASS, "clock_nanosleep call succeeded");
+		                break;
+
+	        default:
+                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
+        		        tst_resm(TINFO,"NG");
+				cleanup();
+				tst_exit();
+		                break;
+        	}
+
+                }
+        }	
+        cleanup();
+	tst_exit();
+}
+
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/clock_nanosleep/Makefile	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/clock_nanosleep/Makefile	2009-05-23 09:41:29.000000000 +0530
@@ -0,0 +1,31 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2009
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+CFLAGS += -I../../../../include -Wall -O2
+LDLIBS += -L../../../../lib -lltp -lrt
+
+SRCS    = $(wildcard *.c)
+TARGETS = $(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+
+clean:
+	rm -f $(TARGETS)
--- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 12:22:30.000000000 +0530
+++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 12:37:07.000000000 +0530
@@ -75,6 +75,7 @@ chroot03 chroot03
 chroot04 chroot04
 
 clock_getres01 clock_getres01
+clock_nanosleep01 clock_nanosleep01
 clock_nanosleep2_01 clock_nanosleep2_01
 
 clone01 clone01

---
Regards--
Manas


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [LTP] [PATCH 05/13] Add/Port mq_notify01 test for mq_notify() syscall
  2009-05-27 10:06 [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Manas Kumar Nayak
                   ` (3 preceding siblings ...)
  2009-05-27 10:08 ` [LTP] [PATCH 04/13] Add/Port clock_nanosleep01 test for clock_nanosleep() syscall Manas Kumar Nayak
@ 2009-05-27 10:09 ` Manas Kumar Nayak
  2009-05-29 12:56   ` Subrata Modak
  2009-05-27 10:09 ` [LTP] [PATCH 06/13] Add/Port ppoll01 test for ppoll() syscall Manas Kumar Nayak
                   ` (8 subsequent siblings)
  13 siblings, 1 reply; 31+ messages in thread
From: Manas Kumar Nayak @ 2009-05-27 10:09 UTC (permalink / raw)
  To: LTP List; +Cc: Manas Kumar Nayak

Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>
To: LTP List <ltp-list@lists.sourceforge.net>
Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
Cc: Masatake YAMATO <yamato@redhat.com>
---

--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_notify/Makefile	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_notify/Makefile	2009-05-23 11:08:05.000000000 +0530
@@ -0,0 +1,31 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2009
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+CFLAGS += -I../../../../include -Wall -O2 -D_POSIX_C_SOURCE=$(shell getconf _POSIX_MESSAGE_PASSING)L
+LDLIBS += -L../../../../lib -lltp -lrt
+
+SRCS    = $(wildcard *.c)
+TARGETS = $(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+
+clean:
+	rm -f $(TARGETS)
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_notify/mq_notify01.c	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_notify/mq_notify01.c	2009-05-27 12:49:33.000000000 +0530
@@ -0,0 +1,477 @@
+/******************************************************************************/
+/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
+/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
+/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
+/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
+/*                                                                  	      */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
+/*                                                                            */
+/******************************************************************************/
+/******************************************************************************/
+/*                                                                            */
+/* File:        mq_notify01.c                                                 */
+/*                                                                            */
+/* Description: This tests the mq_notify() syscall                            */
+/*									      */
+/* 									      */
+/*									      */
+/*									      */
+/*									      */
+/*                                                                            */
+/* Usage:  <for command-line>                                                 */
+/* mq_notify01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                           */
+/*      where,  -c n : Run n copies concurrently.                             */
+/*              -e   : Turn on errno logging.                                 */
+/*              -i n : Execute test n times.                                  */
+/*              -I x : Execute test for x seconds.                            */
+/*              -P x : Pause for x seconds between iterations.                */
+/*              -t   : Turn on syscall timing.                                */
+/*                                                                            */
+/* Total Tests: 1                                                             */
+/*                                                                            */
+/* Test Name:   mq_notify01                                                   */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
+/******************************************************************************/
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/uio.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <mqueue.h>
+#include <signal.h>
+#include <limits.h>
+
+#include "../utils/include_j_h.h"
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+#include "linux_syscall_numbers.h"
+
+/* Extern Global Variables */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "mq_notify01";  /* Test program identifier.*/
+int  testno;
+int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
+
+/* Extern Global Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    cleanup                                                       */
+/*                                                                            */
+/* Description: Performs all one time clean up for this test on successful    */
+/*              completion,  premature exit or  failure. Closes all temporary */
+/*              files, removes all temporary directories exits the test with  */
+/*              appropriate return code by calling tst_exit() function.       */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
+/*              On success - Exits calling tst_exit(). With '0' return code.  */
+/*                                                                            */
+/******************************************************************************/
+extern void cleanup() {
+        /* Remove tmp dir and all files in it */
+        TEST_CLEANUP;
+        tst_rmdir();
+
+        /* Exit with appropriate return code. */
+        tst_exit();
+}
+
+/* Local  Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    setup                                                         */
+/*                                                                            */
+/* Description: Performs all one time setup for this test. This function is   */
+/*              typically used to capture signals, create temporary dirs      */
+/*              and temporary files that may be used in the course of this    */
+/*              test.                                                         */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits by calling cleanup().                      */
+/*              On success - returns 0.                                       */
+/*                                                                            */
+/******************************************************************************/
+void setup() {
+        /* Capture signals if any */
+        /* Create temporary directories */
+        TEST_PAUSE;
+        tst_tmpdir();
+}
+
+
+/*
+ * Macros
+ */
+#define SYSCALL_NAME    "mq_notify"
+
+
+/*
+ * Global variables
+ */
+static int opt_debug;
+static char *progname;
+static int notified;
+static int cmp_ok;
+
+
+enum test_type {
+		NORMAL,
+		FD_NONE,
+	        FD_NOT_EXIST,
+        	FD_FILE,
+	        ALREADY_REGISTERED,
+};
+
+
+/*
+ * Data Structure
+ */
+struct test_case {
+        int notify;
+	int ttype;
+        int ret;
+        int err;
+};
+
+#define MAX_MSGSIZE     8192
+#define MSG_SIZE        16
+#define USER_DATA       0x12345678
+
+
+/* Test cases
+ *
+ *   test status of errors on man page
+ *
+ *   EBADF              v (not a valid descriptor)
+ *   EBUSY              v (process is already registered for notification)
+*/
+
+
+static struct test_case tcase[] = {
+	{ // case00
+                .ttype          = NORMAL,
+                .notify         = SIGEV_NONE,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case01
+                .ttype          = NORMAL,
+                .notify         = SIGEV_SIGNAL,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case02
+                .ttype          = NORMAL,
+                .notify         = SIGEV_THREAD,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case03
+                .ttype          = FD_NONE,
+                .notify         = SIGEV_NONE,
+                .ret            = -1,
+                .err            = EBADF,
+        },
+        { // case04
+                .ttype          = FD_NOT_EXIST,
+                .notify         = SIGEV_NONE,
+                .ret            = -1,
+                .err            = EBADF,
+        },
+        { // case05
+                .ttype          = FD_FILE,
+                .notify         = SIGEV_NONE,
+                .ret            = -1,
+                .err            = EBADF,
+        },
+        { // case06
+                .ttype          = ALREADY_REGISTERED,
+                .notify         = SIGEV_NONE,
+                .ret            = -1,
+                .err            = EBUSY,
+        },
+};
+
+
+static void sigfunc(int signo, siginfo_t *info, void *data)
+{
+        if (opt_debug) {
+                tst_resm(TINFO,"si_code  E:%d,\tR:%d", info->si_code, SI_MESGQ);
+                tst_resm(TINFO,"si_signo E:%d,\tR:%d", info->si_signo, SIGUSR1);
+                tst_resm(TINFO,"si_value E:0x%x,\tR:0x%x", info->si_value.sival_int,USER_DATA);
+                tst_resm(TINFO,"si_pid   E:%d,\tR:%d", info->si_pid, getpid());
+                tst_resm(TINFO,"si_uid   E:%d,\tR:%d", info->si_uid, getuid());
+        }
+        cmp_ok = info->si_code == SI_MESGQ &&
+                 info->si_signo == SIGUSR1 &&
+                 info->si_value.sival_int == USER_DATA &&
+                 info->si_pid == getpid() &&
+                 info->si_uid == getuid();
+        notified = 1;
+}
+
+static void tfunc(union sigval sv)
+{
+        cmp_ok = sv.sival_int == USER_DATA;
+        notified = 1;
+}
+
+/*
+ * do_test()
+ *
+ *   Input  : TestCase Data
+ *   Return : RESULT_OK(0), RESULT_NG(1)
+ *
+ */
+
+static int do_test(struct test_case *tc)
+{
+        int sys_ret;
+        int sys_errno;
+        int result = RESULT_OK;
+        int rc, i, fd = -1;
+        struct sigevent ev;
+        struct sigaction sigact;
+        char smsg[MAX_MSGSIZE];
+
+        notified = cmp_ok = 1;
+
+        /*
+         * When test ended with SIGTERM etc, mq discriptor is left remains.
+         * So we delete it first.
+         */
+        TEST(mq_unlink(QUEUE_NAME));
+
+        switch (tc->ttype) {
+        case FD_NOT_EXIST:
+                fd = INT_MAX - 1;
+                /* fallthrough */
+	case FD_NONE:
+                break;
+        case FD_FILE:
+                TEST(fd = open("/", O_RDONLY));
+                if (TEST_RETURN < 0) {
+                        tst_resm(TFAIL,"can't open \"/\".");
+                        result = 1;
+                        goto EXIT;
+                }
+                break;
+        default:
+                /*
+                 * Open message queue
+                 */
+                TEST(fd = mq_open(QUEUE_NAME, O_CREAT|O_EXCL|O_RDWR, S_IRWXU, NULL));
+                if (TEST_RETURN < 0) {
+                        tst_resm(TFAIL,"mq_open failed errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        result = 1;
+                        goto EXIT;
+                }
+        }
+
+	/*
+         * Set up struct sigevent
+         */
+        ev.sigev_notify = tc->notify;
+        switch (tc->notify) {
+        case SIGEV_SIGNAL:
+                notified = cmp_ok = 0;
+                ev.sigev_signo = SIGUSR1;
+                ev.sigev_value.sival_int = USER_DATA;
+
+                // set up the signal handler
+                memset(&sigact, 0, sizeof(sigact));
+                sigact.sa_sigaction = sigfunc;
+                sigact.sa_flags = SA_SIGINFO;
+                TEST(rc = sigaction(SIGUSR1, &sigact, NULL));
+                break;
+        case SIGEV_THREAD:
+                notified = cmp_ok = 0;
+                ev.sigev_notify_function = tfunc;
+                ev.sigev_notify_attributes = NULL;
+                ev.sigev_value.sival_int = USER_DATA;
+                break;
+        }
+
+	if (tc->ttype == ALREADY_REGISTERED) {
+                TEST(rc = mq_notify(fd, &ev));
+                if (TEST_RETURN < 0) {
+                        tst_resm(TFAIL,"mq_notify failed errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        result = 1;
+                        goto EXIT;
+                }
+        }
+	
+	/*
+         * Execute system call
+         */
+        errno = 0;
+        sys_ret = mq_notify(fd, &ev);
+        sys_errno = errno;
+        if (sys_ret < 0)
+                goto TEST_END;
+
+	 /*
+         * Prepare send message
+         */
+        for (i = 0; i < MSG_SIZE; i++)
+                smsg[i] = i;
+        TEST(rc = mq_timedsend(fd, smsg, MSG_SIZE, 0, NULL));
+        if (rc < 0) {
+                tst_resm(TFAIL,"mq_timedsend failed errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                result = 1;
+                goto EXIT;
+        }
+
+        while (!notified)
+                usleep(10000);
+
+TEST_END:
+        /*
+         * Check results
+         */
+        result |= (sys_errno != tc->err) || !cmp_ok;
+        PRINT_RESULT_CMP(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno,
+                         cmp_ok);
+
+EXIT:
+        if (fd >= 0) {
+                close(fd);
+                mq_unlink(QUEUE_NAME);
+        }
+
+        return result;
+}
+	
+
+
+/*
+ * usage()
+ */
+
+static void usage(const char *progname)
+{
+        tst_resm(TINFO,"usage: %s [options]", progname);
+        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
+        tst_resm(TINFO,"options:");
+        tst_resm(TINFO,"    -d --debug           Show debug messages");
+        tst_resm(TINFO,"    -h --help            Show this message");
+        tst_resm(TINFO,"NG");
+        exit(1);
+}
+
+
+/*
+ * main()
+ */
+
+
+
+int main(int ac, char **av) {
+	int result = RESULT_OK;
+        int c;
+        int i;
+        int lc;                 /* loop counter */
+        char *msg;              /* message returned from parse_opts */
+
+	struct option long_options[] = {
+                { "debug", no_argument, 0, 'd' },
+                { "help",  no_argument, 0, 'h' },
+                { NULL, 0, NULL, 0 }
+        };
+
+	progname = strchr(av[0], '/');
+        progname = progname ? progname + 1 : av[0];	
+	
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
+
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
+			 while(TEST_RETURN != -1) {
+		                switch (c) {
+                		case 'd':
+		                        opt_debug = 1;
+                		        break;
+		                default:
+                		        usage(progname);
+                        		// NOTREACHED
+                		}
+		        }
+
+
+		if (ac != optind) {
+        	        tst_resm(TINFO,"Options are not match.");
+                	usage(progname);
+                	// NOTREACHED
+	        }
+
+		/*
+		* Execute test
+         	*/
+	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
+        	        int ret;
+	                tst_resm(TINFO,"(case%02d) START", i);
+	                ret = do_test(&tcase[i]);
+	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
+	                result |= ret;
+        	}
+		
+		/*
+        	 * Check results
+         	*/
+        	switch(result) {
+	        case RESULT_OK:
+        			tst_resm(TPASS, "mq_notify call succeeded");
+		                break;
+
+	        default:
+                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
+        		        tst_resm(TINFO,"NG");
+				cleanup();
+				tst_exit();
+		                break;
+        	}
+
+                }
+        }	
+        cleanup();
+	tst_exit();
+}
+
--- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 12:45:56.000000000 +0530
+++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 12:55:31.000000000 +0530
@@ -585,6 +585,8 @@ mprotect01 mprotect01
 mprotect02 mprotect02
 mprotect03 mprotect03
 
+mq_notify01 mq_notify01
+
 mremap01 mremap01
 mremap02 mremap02
 mremap03 mremap03

---
Regards--
Manas


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [LTP] [PATCH 06/13]  Add/Port ppoll01 test for ppoll() syscall
  2009-05-27 10:06 [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Manas Kumar Nayak
                   ` (4 preceding siblings ...)
  2009-05-27 10:09 ` [LTP] [PATCH 05/13] Add/Port mq_notify01 test for mq_notify() syscall Manas Kumar Nayak
@ 2009-05-27 10:09 ` Manas Kumar Nayak
  2009-05-29 12:56   ` Subrata Modak
  2009-05-27 10:10 ` [LTP] [PATCH 07/13] Add/Port mq_open01 test for mq_open() syscall Manas Kumar Nayak
                   ` (7 subsequent siblings)
  13 siblings, 1 reply; 31+ messages in thread
From: Manas Kumar Nayak @ 2009-05-27 10:09 UTC (permalink / raw)
  To: LTP List; +Cc: Manas Kumar Nayak

diff -uprN ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/Makefile ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/Makefile
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/Makefile	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/Makefile	2009-05-23 12:01:25.000000000 +0530
@@ -0,0 +1,31 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2009
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+CFLAGS += -I../../../../include -Wall -O2
+LDLIBS += -L../../../../lib -lltp 
+
+SRCS    = $(wildcard *.c)
+TARGETS = $(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+
+clean:
+	rm -f $(TARGETS)
diff -uprN ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/ppoll01.c ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/ppoll01.c
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/ppoll01.c	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/ppoll01.c	2009-05-27 13:00:58.000000000 +0530
@@ -0,0 +1,482 @@
+/******************************************************************************/
+/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
+/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
+/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
+/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
+/*                                                                  	      */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
+/*                                                                            */
+/******************************************************************************/
+/******************************************************************************/
+/*                                                                            */
+/* File:        ppoll01.c                                                     */
+/*                                                                            */
+/* Description: This tests the ppoll01() syscall                              */
+/*									      */
+/* 									      */
+/*									      */
+/*									      */
+/*									      */
+/*                                                                            */
+/* Usage:  <for command-line>                                                 */
+/* ppoll01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                               */
+/*      where,  -c n : Run n copies concurrently.                             */
+/*              -e   : Turn on errno logging.                                 */
+/*              -i n : Execute test n times.                                  */
+/*              -I x : Execute test for x seconds.                            */
+/*              -P x : Pause for x seconds between iterations.                */
+/*              -t   : Turn on syscall timing.                                */
+/*                                                                            */
+/* Total Tests: 1                                                             */
+/*                                                                            */
+/* Test Name:   ppoll01                                                       */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
+/******************************************************************************/
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <sys/select.h>
+#include <sys/wait.h>
+#include <getopt.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <libgen.h>
+#include <limits.h>
+#include <signal.h>
+#include "asm/poll.h"
+
+
+#include "../utils/include_j_h.h"
+#include "../utils/common_j_h.c"
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+#include "linux_syscall_numbers.h"
+
+/* Extern Global Variables */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "ppoll01";  /* Test program identifier.*/
+int  testno;
+int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
+
+/* Extern Global Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    cleanup                                                       */
+/*                                                                            */
+/* Description: Performs all one time clean up for this test on successful    */
+/*              completion,  premature exit or  failure. Closes all temporary */
+/*              files, removes all temporary directories exits the test with  */
+/*              appropriate return code by calling tst_exit() function.       */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
+/*              On success - Exits calling tst_exit(). With '0' return code.  */
+/*                                                                            */
+/******************************************************************************/
+extern void cleanup() {
+        /* Remove tmp dir and all files in it */
+        TEST_CLEANUP;
+        tst_rmdir();
+
+        /* Exit with appropriate return code. */
+        tst_exit();
+}
+
+/* Local  Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    setup                                                         */
+/*                                                                            */
+/* Description: Performs all one time setup for this test. This function is   */
+/*              typically used to capture signals, create temporary dirs      */
+/*              and temporary files that may be used in the course of this    */
+/*              test.                                                         */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits by calling cleanup().                      */
+/*              On success - returns 0.                                       */
+/*                                                                            */
+/******************************************************************************/
+void setup() {
+        /* Capture signals if any */
+        /* Create temporary directories */
+        TEST_PAUSE;
+        tst_tmpdir();
+}
+
+
+/*
+ * Macros
+ */
+#define SYSCALL_NAME    "ppoll"
+
+#ifndef __NR_ppoll
+#  define __NR_ppoll    309
+#endif
+
+#ifndef POLLRDHUP
+#  define POLLRDHUP     0x2000
+#endif
+
+
+/*
+ * Global variables
+ */
+static int opt_debug;
+static char *progname;
+static char *progdir;
+
+enum test_type {
+	NORMAL,
+        MASK_SIGNAL,
+        TIMEOUT,
+        FD_ALREADY_CLOSED,
+        SEND_SIGINT,
+        INVALID_NFDS,
+        INVALID_FDS,
+        MINUS_NSEC,
+        TOO_LARGE_NSEC,
+
+};
+
+
+/*
+ * Data Structure
+ */
+struct test_case {
+	short expect_revents;
+        int ttype;
+        int ret;
+        int err;
+};
+
+
+/* Test cases
+ *
+ *   test status of errors on man page
+ *
+ *   EBADF              can't check because EBADF never happen even though
+ *                      fd was invalid. In this case, information of invalid
+ *                      fd is set in revents
+ *   EFAULT             v ('fds' array in the invalid address space)
+ *   EINTR              v (a non blocked signal was caught)
+ *   EINVAL             v ('nfds' is over the 'RLIMIT_NOFILE' value)
+ *   ENOMEM             can't check because it's difficult to create no-memory
+ */
+
+
+static struct test_case tcase[] = {
+	{ // case00
+                .ttype          = NORMAL,
+                .expect_revents = POLLOUT,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case01
+                .ttype          = MASK_SIGNAL,
+                .expect_revents = 0, // don't care
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case02
+                .ttype          = TIMEOUT,
+                .expect_revents = 0, // don't care
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case03
+                .ttype          = FD_ALREADY_CLOSED,
+                .expect_revents = POLLNVAL,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case04
+                .ttype          = SEND_SIGINT,
+                .ret            = -1,
+                .err            = EINTR,
+        },
+        { // case05
+                .ttype          = INVALID_NFDS,
+                .ret            = -1,
+                .err            = EINVAL,
+        },
+        { // case06
+                .ttype          = INVALID_FDS,
+                .ret            = -1,
+                .err            = EFAULT,
+        },
+#if 0
+        { // case07
+                .ttype          = MINUS_NSEC,
+                .ret            = -1,
+                .err            = EINVAL, // RHEL4U1 + 2.6.18 returns SUCCESS
+        },
+        { // case08
+                .ttype          = TOO_LARGE_NSEC,
+                .ret            = -1,
+                .err            = EINVAL, // RHEL4U1 + 2.6.18 returns SUCCESS
+        },
+#endif
+};
+
+#define NUM_TEST_FDS    1
+
+/*
+ * do_test()
+ *
+ *   Input  : TestCase Data
+ *   Return : RESULT_OK(0), RESULT_NG(1)
+ *
+ */
+
+static int do_test(struct test_case *tc)
+{
+        int sys_ret;
+        int sys_errno;
+        int result = RESULT_OK;
+	int fd = -1 , cmp_ok = 1;
+	char fpath[PATH_MAX];
+	struct pollfd *p_fds, fds[NUM_TEST_FDS];
+        unsigned int nfds = NUM_TEST_FDS;
+        struct timespec *p_ts, ts;
+        sigset_t *p_sigmask, sigmask;
+        size_t sigsetsize = 0;
+        pid_t pid = 0;
+
+	TEST(fd = setup_file(progdir, "test.file", fpath));
+        if (fd < 0)
+                return 1;
+        fds[0].fd = fd;
+        fds[0].events = POLLIN | POLLPRI | POLLOUT | POLLRDHUP;
+        fds[0].revents = 0;
+        p_fds = fds;
+        p_ts = NULL;
+        p_sigmask = NULL;
+
+	switch (tc->ttype) {
+        case TIMEOUT:
+                nfds = 0;
+                ts.tv_sec = 0;
+                ts.tv_nsec = 50000000;  // 50msec
+                p_ts = &ts;
+                break;
+	case FD_ALREADY_CLOSED:
+                TEST(close(fd));
+                fd = -1;
+                TEST(cleanup_file(fpath));
+                break;
+        case MASK_SIGNAL:
+                TEST(sigemptyset(&sigmask));
+                TEST(sigaddset(&sigmask, SIGINT));
+                p_sigmask = &sigmask;
+                //sigsetsize = sizeof(sigmask);
+                sigsetsize = 8;
+                nfds = 0;
+                ts.tv_sec = 0;
+                ts.tv_nsec = 300000000; // 300msec => need to be enough for
+                                        //   waiting the signal
+                p_ts = &ts;
+                // fallthrough
+	case SEND_SIGINT:
+                nfds = 0;
+                TEST(pid = create_sig_proc(100000, SIGINT)); // 100msec
+                if (pid < 0)
+                        return 1;
+                break;
+        case INVALID_NFDS:
+                //nfds = RLIMIT_NOFILE + 1; ==> RHEL4U1 + 2.6.18 returns SUCCESS
+                nfds = -1;
+                break;
+        case INVALID_FDS:
+                p_fds = (void*)0xc0000000;
+                break;
+        case MINUS_NSEC:
+                ts.tv_sec = 0;
+                ts.tv_nsec = -1;
+                p_ts = &ts;
+                break;
+	case TOO_LARGE_NSEC:
+                ts.tv_sec = 0;
+                ts.tv_nsec = 1000000000;
+                p_ts = &ts;
+                break;
+        }
+
+	/*
+	   * Execute system call
+         */
+        errno = 0;
+        TEST(sys_ret = syscall(__NR_ppoll, p_fds, nfds, p_ts, p_sigmask, sigsetsize));
+        sys_errno = errno;
+        if (sys_ret <= 0 || tc->ret < 0)
+                goto TEST_END;
+
+        cmp_ok = fds[0].revents == tc->expect_revents;
+        if (opt_debug) {
+                tst_resm(TINFO,"EXPECT: revents=0x%04x", tc->expect_revents);
+                tst_resm(TINFO,"RESULT: revents=0x%04x", fds[0].revents);
+        }
+
+TEST_END:
+        /*
+         * Check results
+         */
+        result |= (sys_errno != tc->err) || !cmp_ok;
+        PRINT_RESULT_CMP(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno,
+                         cmp_ok);
+
+        if (fd >= 0)
+                cleanup_file(fpath);
+        if (pid > 0) {
+                int st;
+                kill(pid, SIGTERM);
+                wait(&st);
+        }
+	return result;
+}
+
+
+/*
+ * sighandler()
+ */
+void sighandler(int sig)
+{
+        if (sig == SIGINT)
+                return;
+        // NOTREACHED
+        return;
+}
+
+
+/*
+ * usage()
+ */
+
+static void usage(const char *progname)
+{
+        tst_resm(TINFO,"usage: %s [options]", progname);
+        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
+        tst_resm(TINFO,"options:");
+        tst_resm(TINFO,"    -d --debug           Show debug messages");
+        tst_resm(TINFO,"    -h --help            Show this message");
+        tst_resm(TINFO,"NG");
+        exit(1);
+}
+
+
+/*
+ * main()
+ */
+
+
+
+int main(int ac, char **av) {
+	int result = RESULT_OK;
+        int c;
+        int i;
+        int lc;                 /* loop counter */
+        char *msg;              /* message returned from parse_opts */
+
+	struct option long_options[] = {
+                { "debug", no_argument, 0, 'd' },
+                { "help",  no_argument, 0, 'h' },
+                { NULL, 0, NULL, 0 }
+        };
+
+	progname = strchr(av[0], '/');
+        progname = progname ? progname + 1 : av[0];	
+
+	progdir = strdup(av[0]);
+        progdir = dirname(progdir);
+	
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
+
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
+			 while(TEST_RETURN != -1) {
+		                switch (c) {
+                		case 'd':
+		                        opt_debug = 1;
+                		        break;
+		                default:
+                		        usage(progname);
+                        		// NOTREACHED
+                		}
+		        }
+
+
+		if (ac != optind) {
+        	        tst_resm(TINFO,"Options are not match.");
+                	usage(progname);
+                	// NOTREACHED
+	        }
+
+		/*
+		* Execute test
+         	*/
+	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
+        	        int ret;
+	                tst_resm(TINFO,"(case%02d) START", i);
+	                ret = do_test(&tcase[i]);
+	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
+	                result |= ret;
+        	}
+		
+		/*
+        	 * Check results
+         	*/
+        	switch(result) {
+	        case RESULT_OK:
+        			tst_resm(TPASS, "ppoll01 call succeeded ");
+		                break;
+
+	        default:
+                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
+        		        RPRINTF("NG");
+				cleanup();
+				tst_exit();
+		                break;
+        	}
+
+                }
+        }	
+        cleanup();
+	tst_exit();
+}
+
--- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 12:58:57.000000000 +0530
+++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 13:06:52.000000000 +0530
@@ -706,6 +706,8 @@ pipe2_02 pipe2_02
 
 poll01 poll01
 
+ppoll01 ppoll01
+
 prctl01 prctl01
 prctl02 prctl02
 

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [LTP] [PATCH 07/13] Add/Port mq_open01 test for mq_open() syscall
  2009-05-27 10:06 [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Manas Kumar Nayak
                   ` (5 preceding siblings ...)
  2009-05-27 10:09 ` [LTP] [PATCH 06/13] Add/Port ppoll01 test for ppoll() syscall Manas Kumar Nayak
@ 2009-05-27 10:10 ` Manas Kumar Nayak
  2009-05-29 12:56   ` Subrata Modak
  2009-05-27 10:10 ` [LTP] [PATCH 08/13] Add/Port mq_timedreceive01 test for mq_timedreceive() syscall Manas Kumar Nayak
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 31+ messages in thread
From: Manas Kumar Nayak @ 2009-05-27 10:10 UTC (permalink / raw)
  To: LTP List; +Cc: Manas Kumar Nayak

Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>
To: LTP List <ltp-list@lists.sourceforge.net>
Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
Cc: Masatake YAMATO <yamato@redhat.com>
---

--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_open/Makefile	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_open/Makefile	2009-05-23 12:03:30.000000000 +0530
@@ -0,0 +1,31 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2009
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+CFLAGS += -I../../../../include -Wall -O2
+LDLIBS += -L../../../../lib -lltp -lrt
+
+SRCS    = $(wildcard *.c)
+TARGETS = $(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+
+clean:
+	rm -f $(TARGETS)
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_open/mq_open01.c	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_open/mq_open01.c	2009-05-27 13:11:05.000000000 +0530
@@ -0,0 +1,520 @@
+/******************************************************************************/
+/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
+/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
+/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
+/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
+/*                                                                  	      */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
+/*                                                                            */
+/******************************************************************************/
+/******************************************************************************/
+/*                                                                            */
+/* File:        mq_open01.c                                                   */
+/*                                                                            */
+/* Description: This tests the mq_open() syscall                              */
+/*									      */
+/* 									      */
+/*									      */
+/*									      */
+/*									      */
+/*                                                                            */
+/* Usage:  <for command-line>                                                 */
+/* mq_open01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                             */
+/*      where,  -c n : Run n copies concurrently.                             */
+/*              -e   : Turn on errno logging.                                 */
+/*              -i n : Execute test n times.                                  */
+/*              -I x : Execute test for x seconds.                            */
+/*              -P x : Pause for x seconds between iterations.                */
+/*              -t   : Turn on syscall timing.                                */
+/*                                                                            */
+/* Total Tests: 1                                                             */
+/*                                                                            */
+/* Test Name:   mq_open01                                                     */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
+/******************************************************************************/
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/uio.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <mqueue.h>
+#include <limits.h>
+
+
+#include "../utils/include_j_h.h"
+#include "../utils/common_j_h.c"
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+#include "linux_syscall_numbers.h"
+
+/* Extern Global Variables */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "mq_open01";  /* Test program identifier.*/
+int  testno;
+int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
+
+/* Extern Global Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    cleanup                                                       */
+/*                                                                            */
+/* Description: Performs all one time clean up for this test on successful    */
+/*              completion,  premature exit or  failure. Closes all temporary */
+/*              files, removes all temporary directories exits the test with  */
+/*              appropriate return code by calling tst_exit() function.       */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
+/*              On success - Exits calling tst_exit(). With '0' return code.  */
+/*                                                                            */
+/******************************************************************************/
+extern void cleanup() {
+        /* Remove tmp dir and all files in it */
+        TEST_CLEANUP;
+        tst_rmdir();
+
+        /* Exit with appropriate return code. */
+        tst_exit();
+}
+
+/* Local  Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    setup                                                         */
+/*                                                                            */
+/* Description: Performs all one time setup for this test. This function is   */
+/*              typically used to capture signals, create temporary dirs      */
+/*              and temporary files that may be used in the course of this    */
+/*              test.                                                         */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits by calling cleanup().                      */
+/*              On success - returns 0.                                       */
+/*                                                                            */
+/******************************************************************************/
+void setup() {
+        /* Capture signals if any */
+        /* Create temporary directories */
+        TEST_PAUSE;
+        tst_tmpdir();
+}
+
+
+/*
+ * Macros
+ */
+#define SYSCALL_NAME    "mq_open"
+
+#ifndef __NR_mq_getsetattr
+#  define __NR_mq_getsetattr            282
+#endif
+
+
+/*
+ * Global variables
+ */
+static int opt_debug;
+static char *progname;
+
+enum test_type {
+		NORMAL,
+		NO_FILE,
+	        NO_SPACE,
+};
+
+
+/*
+ * Data Structure
+ */
+struct test_case {
+	int ttype;
+        char *user;
+        char *qname;
+        int oflag;
+        long mq_maxmsg;         // Maximum numebr of messages.
+        long mq_msgsize;        // Maximum message size.
+        int ret;
+        int err;
+};
+
+#define ULIMIT_FNUM     0
+#define PROC_MAX_QUEUES "/proc/sys/fs/mqueue/queues_max"
+
+/* Test cases
+ *
+ *   test status of errors on man page
+ *
+ *   EACCES             v (permission is denied)
+ *   EEXIST             v (named message queue already exists)
+ *   EINTR              --- (interrupted by a signal)
+ *   EINVAL             v (not supported for the given name, or invalid
+ *                         arguments)
+ *   EMFILE             v (process file table overflow)
+ *   ENAMETOOLONG       v (too long name length)
+ *   ENFILE             can't check because it's difficult to create no-fd
+ *   ENOENT             v (O_CREAT is not set and the named message queue
+ *                         does not exist)
+ *   ENOSPC             v (no space for the new message queue)
+ */
+
+
+static struct test_case tcase[] = {
+#if 1
+        { // case00
+                .ttype          = NORMAL,
+                .qname          = QUEUE_NAME,
+                .oflag          = O_CREAT,
+                .mq_maxmsg      = 20,
+                .mq_msgsize     = 16384,
+                .ret            = 0,
+                .err            = 0,
+        },
+#else
+        { // case00
+                .ttype          = NORMAL,
+                .qname          = QUEUE_NAME,
+                .oflag          = O_CREAT,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case01
+                .ttype          = NORMAL,
+                                //  0         1         2         3
+                                //  0123456789012345678901234567890123456789
+                .qname          = "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaa",
+                .oflag          = O_CREAT,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case02
+                .ttype          = NORMAL,
+                                //  0         1         2         3
+                                //  0123456789012345678901234567890123456789
+                .qname          = "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaa",
+                .oflag          = O_CREAT,
+                .ret            = -1,
+                .err            = ENAMETOOLONG,
+        },
+
+	{ // case03
+                .ttype          = NORMAL,
+                .qname          = "",
+                .oflag          = O_CREAT,
+                .ret            = -1,
+                .err            = EINVAL,
+        },
+        { // case04
+                .ttype          = NORMAL,
+                .user           = "nobody",
+                .qname          = QUEUE_NAME,
+                .ret            = -1,
+                .err            = EACCES,
+        },
+        { // case05
+                .ttype          = NORMAL,
+                .qname          = QUEUE_NAME,
+                .oflag          = O_CREAT|O_EXCL,
+                .ret            = -1,
+                .err            = EEXIST,
+        },
+        { // case06
+                .ttype          = NO_FILE,
+                .qname          = QUEUE_NAME,
+                .oflag          = O_CREAT,
+                .ret            = -1,
+                .err            = EMFILE,
+        },
+        { // case07
+                .ttype          = NORMAL,
+                .qname          = "/notexist",
+                .oflag          = 0,
+                .ret            = -1,
+                .err            = ENOENT,
+        },
+
+	{ // case08
+                .ttype          = NO_SPACE,
+                .user           = "nobody",
+                .qname          = QUEUE_NAME,
+                .oflag          = O_CREAT,
+                .ret            = -1,
+                .err            = ENOSPC,
+        },
+#endif
+};
+
+
+/*
+ * do_test()
+ *
+ *   Input  : TestCase Data
+ *   Return : RESULT_OK(0), RESULT_NG(1)
+ *
+ */
+
+static int do_test(struct test_case *tc)
+{
+        int sys_ret;
+        int sys_errno;
+        int result = RESULT_OK;
+	int rc, fd1 = -1, fd2 = -1, cmp_ok = 1;
+        uid_t old_uid = -1;
+        rlim_t oldlim = -1;
+        int oldval = -1;
+        struct mq_attr new, old, *p_attr;
+	
+	 /*
+         * When test ended with SIGTERM etc, mq discriptor is left remains.
+         * So we delete it first.
+         */
+        TEST(mq_unlink(QUEUE_NAME));
+
+	
+	/*
+         * Execute system call
+         */
+
+	if (tc->ttype != NO_SPACE) {
+                errno = 0;
+                TEST(sys_ret = mq_open(QUEUE_NAME, O_CREAT|O_EXCL|O_RDWR, S_IRWXU, NULL));
+                sys_errno = errno;
+                if (sys_ret < 0)
+                        goto TEST_END;
+                fd1 = sys_ret;
+        }
+	if (tc->ttype == NO_FILE) {
+                TEST(rc = setup_ulimit_fnum(ULIMIT_FNUM, &oldlim));
+                if (rc < 0) {
+                        result = 1;
+                        goto EXIT;
+                }
+        }
+
+	/*
+         * Change /proc/sys/fs/mqueue/queues_max
+         */
+        if (tc->ttype == NO_SPACE) {
+                TEST(rc = setup_proc_fs(PROC_MAX_QUEUES, 0, &oldval));
+                if (rc < 0) {
+                        result = 1;
+                        goto EXIT;
+                }
+        }
+
+	/*
+         * Change effective user id
+         */
+        if (tc->user != NULL) {
+                TEST(rc = setup_euid(tc->user, &old_uid));
+                if (rc < 0) {
+                        result = 1;
+                        goto EXIT;
+                }
+        }
+
+	 /*
+         * Execute system call
+         */
+        //tst_resm(TINFO,"PATH_MAX: %d\n", PATH_MAX);
+        //tst_resm(TINFO,"NAME_MAX: %d", NAME_MAX);
+        p_attr = NULL;
+        if (tc->mq_maxmsg || tc->mq_msgsize) {
+                new.mq_maxmsg = tc->mq_maxmsg;
+                new.mq_msgsize = tc->mq_msgsize;
+                p_attr = &new;
+        }
+        errno = 0;
+	if (tc->oflag & O_CREAT)
+                TEST(sys_ret = mq_open(tc->qname, tc->oflag, S_IRWXU, p_attr));
+        else
+                TEST(sys_ret = mq_open(tc->qname, tc->oflag));
+        sys_errno = errno;
+        if (sys_ret < 0)
+                goto TEST_END;
+        fd2 = sys_ret;
+
+        if (p_attr) {
+                TEST(rc = syscall(__NR_mq_getsetattr, fd2, NULL, &old));
+                if (TEST_RETURN < 0) {
+                 	tst_resm(TFAIL, "mq_getsetattr failed - errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        result = 1;
+                        goto EXIT;
+                }
+		if (opt_debug) {
+                        tst_resm(TINFO,"mq_maxmsg E:%ld,\tR:%ld",new.mq_maxmsg, old.mq_maxmsg);
+                        tst_resm(TINFO,"mq_msgsize E:%ld,\tR:%ld",new.mq_msgsize, old.mq_msgsize);
+                }
+                cmp_ok = old.mq_maxmsg == new.mq_maxmsg &&
+                         old.mq_msgsize == new.mq_msgsize;
+        }
+
+TEST_END:
+        /*
+         * Check results
+         */
+        result |= (sys_errno != tc->err) || !cmp_ok;
+        PRINT_RESULT_CMP(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno,cmp_ok);
+
+EXIT:
+        if (tc->user != NULL && old_uid != -1)
+                TEST(cleanup_euid(old_uid));
+
+        if (tc->ttype == NO_SPACE && oldval != -1)
+                TEST(cleanup_proc_fs(PROC_MAX_QUEUES, oldval));
+
+        if (tc->ttype == NO_FILE && oldlim != -1)
+                TEST(cleanup_ulimit_fnum(oldlim));
+	 if (fd1 >= 0)
+                TEST(close(fd1));
+        if (fd2 >= 0)
+                TEST(close(fd2));
+        if (fd1 >= 0)
+                TEST(mq_unlink(QUEUE_NAME));
+        if (fd2 >= 0 && strcmp(tc->qname, QUEUE_NAME) != 0)
+                TEST(mq_unlink(tc->qname));
+
+        return result;
+}
+
+
+/*
+ * usage()
+ */
+
+static void usage(const char *progname)
+{
+        tst_resm(TINFO,"usage: %s [options]", progname);
+        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
+        tst_resm(TINFO,"options:");
+        tst_resm(TINFO,"    -d --debug           Show debug messages");
+        tst_resm(TINFO,"    -h --help            Show this message");
+        tst_resm(TINFO,"NG");
+        exit(1);
+}
+
+
+/*
+ * main()
+ */
+
+int main(int ac, char **av) {
+	int result = RESULT_OK;
+        int c;
+        int i;
+        int lc;                 /* loop counter */
+        char *msg;              /* message returned from parse_opts */
+
+	struct option long_options[] = {
+                { "debug", no_argument, 0, 'd' },
+                { "help",  no_argument, 0, 'h' },
+                { NULL, 0, NULL, 0 }
+        };
+
+	progname = strchr(av[0], '/');
+        progname = progname ? progname + 1 : av[0];	
+	
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
+
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
+			 while(TEST_RETURN != -1) {
+		                switch (c) {
+                		case 'd':
+		                        opt_debug = 1;
+                		        break;
+		                default:
+                		        usage(progname);
+                        		// NOTREACHED
+                		}
+		        }
+
+
+		if (ac != optind) {
+        	        tst_resm(TINFO,"Options are not match.");
+                	usage(progname);
+                	// NOTREACHED
+	        }
+
+		/*
+		* Execute test
+         	*/
+	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
+        	        int ret;
+	                tst_resm(TINFO,"(case%02d) START", i);
+	                ret = do_test(&tcase[i]);
+	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
+	                result |= ret;
+        	}
+		
+		/*
+        	 * Check results
+         	*/
+        	switch(result) {
+	        case RESULT_OK:
+        			tst_resm(TPASS, "mq_open call succeeded ");
+		                break;
+
+	        default:
+                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
+        		        tst_resm(TINFO,"NG");
+				cleanup();
+				tst_exit();
+		                break;
+        	}
+
+                }
+        }	
+        cleanup();
+	tst_exit();
+}
+
--- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 13:08:52.000000000 +0530
+++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 13:20:31.000000000 +0530
@@ -586,6 +586,7 @@ mprotect02 mprotect02
 mprotect03 mprotect03
 
 mq_notify01 mq_notify01
+mq_open01 mq_open01
 
 mremap01 mremap01
 mremap02 mremap02

---
Regards--
Manas


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [LTP] [PATCH 08/13] Add/Port mq_timedreceive01 test for mq_timedreceive() syscall
  2009-05-27 10:06 [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Manas Kumar Nayak
                   ` (6 preceding siblings ...)
  2009-05-27 10:10 ` [LTP] [PATCH 07/13] Add/Port mq_open01 test for mq_open() syscall Manas Kumar Nayak
@ 2009-05-27 10:10 ` Manas Kumar Nayak
  2009-05-29 12:56   ` Subrata Modak
  2009-05-27 10:11 ` [LTP] [PATCH 09/13] Add/Port utimes01 test for utimes() syscall Manas Kumar Nayak
                   ` (5 subsequent siblings)
  13 siblings, 1 reply; 31+ messages in thread
From: Manas Kumar Nayak @ 2009-05-27 10:10 UTC (permalink / raw)
  To: LTP List; +Cc: Manas Kumar Nayak

Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>
To: LTP List <ltp-list@lists.sourceforge.net>
Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
Cc: Masatake YAMATO <yamato@redhat.com>
---

--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_timedreceive/Makefile	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_timedreceive/Makefile	2009-05-23 14:30:57.000000000 +0530
@@ -0,0 +1,31 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2009
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+CFLAGS += -I../../../../include -Wall -O2 -D_POSIX_C_SOURCE=$(shell getconf _POSIX_MESSAGE_PASSING)L
+LDLIBS += -L../../../../lib -lltp -lrt
+
+SRCS    = $(wildcard *.c)
+TARGETS = $(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+
+clean:
+	rm -f $(TARGETS)
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c	2009-05-27 13:23:51.000000000 +0530
@@ -0,0 +1,548 @@
+/******************************************************************************/
+/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
+/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
+/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
+/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
+/*                                                                  	      */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
+/*                                                                            */
+/******************************************************************************/
+/******************************************************************************/
+/*                                                                            */
+/* File:        mq_timedreceive01.c                                           */
+/*                                                                            */
+/* Description: This tests the mq_timedreceive() syscall                      */
+/*									      */
+/* 									      */
+/*									      */
+/*									      */
+/*									      */
+/*                                                                            */
+/* Usage:  <for command-line>                                                 */
+/* mq_timedreceive01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                     */
+/*      where,  -c n : Run n copies concurrently.                             */
+/*              -e   : Turn on errno logging.                                 */
+/*              -i n : Execute test n times.                                  */
+/*              -I x : Execute test for x seconds.                            */
+/*              -P x : Pause for x seconds between iterations.                */
+/*              -t   : Turn on syscall timing.                                */
+/*                                                                            */
+/* Total Tests: 1                                                             */
+/*                                                                            */
+/* Test Name:   mq_timedreceive01                                             */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
+/******************************************************************************/
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <mqueue.h>
+#include <time.h>
+#include <signal.h>
+#include <limits.h>
+
+
+#include "../utils/include_j_h.h"
+#include "../utils/common_j_h.c"
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+#include "linux_syscall_numbers.h"
+
+/* Extern Global Variables */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "mq_timedreceive01";  /* Test program identifier.*/
+int  testno;
+int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
+
+/* Extern Global Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    cleanup                                                       */
+/*                                                                            */
+/* Description: Performs all one time clean up for this test on successful    */
+/*              completion,  premature exit or  failure. Closes all temporary */
+/*              files, removes all temporary directories exits the test with  */
+/*              appropriate return code by calling tst_exit() function.       */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
+/*              On success - Exits calling tst_exit(). With '0' return code.  */
+/*                                                                            */
+/******************************************************************************/
+extern void cleanup() {
+        /* Remove tmp dir and all files in it */
+        TEST_CLEANUP;
+        tst_rmdir();
+
+        /* Exit with appropriate return code. */
+        tst_exit();
+}
+
+/* Local  Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    setup                                                         */
+/*                                                                            */
+/* Description: Performs all one time setup for this test. This function is   */
+/*              typically used to capture signals, create temporary dirs      */
+/*              and temporary files that may be used in the course of this    */
+/*              test.                                                         */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits by calling cleanup().                      */
+/*              On success - returns 0.                                       */
+/*                                                                            */
+/******************************************************************************/
+void setup() {
+        /* Capture signals if any */
+        /* Create temporary directories */
+        TEST_PAUSE;
+        tst_tmpdir();
+}
+
+
+/*
+ * Macros
+ */
+#define SYSCALL_NAME    "mq_timedreceive"
+
+
+/*
+ * Global variables
+ */
+static int opt_debug;
+static char *progname;
+
+enum test_type {
+	NORMAL,
+        FD_NONE,
+        FD_NOT_EXIST,
+        FD_FILE,
+        INVALID_MSG_LEN,
+        EMPTY_QUEUE,
+        SEND_SIGINT,
+};
+
+
+/*
+ * Data Structure
+ */
+struct test_case {
+	int ttype;
+        int non_block;
+        int len;
+        unsigned prio;
+        time_t sec;
+        long nsec;
+        int ret;
+        int err;
+};
+
+#define MAX_MSG         10
+#define MAX_MSGSIZE     8192
+
+/* Test cases
+ *
+ *   test status of errors on man page
+ *
+ *   EAGAIN             v (would block)
+ *   EBADF              v (not a valid descriptor)
+ *   EINTR              v (interrupted by a signal)
+ *   EINVAL             v (invalid timeout value)
+ *   ETIMEDOUT          v (not block and timeout occured)
+ *   EMSGSIZE           v ('msg_len' is less than the message size of the queue)
+ *   EBADMSG            can't check because this error never occur
+ */
+static struct test_case tcase[] = {
+        { // case00
+                .ttype          = NORMAL,
+                .len            = 0,    // also success when size equals zero
+                .ret            = 0,
+                .err            = 0,
+        },
+	{ // case01
+                .ttype          = NORMAL,
+                .len            = 1,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case02
+                .ttype          = NORMAL,
+                .len            = MAX_MSGSIZE,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case03
+                .ttype          = NORMAL,
+                .len            = 1,
+                .prio           = 32767, // max priority
+                .ret            = 0,
+                .err            = 0,
+        },
+	{ // case04
+                .ttype          = INVALID_MSG_LEN,
+                .len            = 0,
+                .ret            = -1,
+                .err            = EMSGSIZE,
+        },
+        { // case05
+                .ttype          = FD_NONE,
+                .len            = 0,
+                .ret            = -1,
+                .err            = EBADF,
+        },
+        { // case06
+                .ttype          = FD_NOT_EXIST,
+                .len            = 0,
+                .ret            = -1,
+                .err            = EBADF,
+        },
+        { // case07
+                .ttype          = FD_FILE,
+                .len            = 0,
+                .ret            = -1,
+                .err            = EBADF,
+        },
+        { // case08
+                .ttype          = EMPTY_QUEUE,
+                .non_block      = 1,
+                .len            = 16,
+                .ret            = -1,
+                .err            = EAGAIN,
+        },
+        { // case09
+                .ttype          = EMPTY_QUEUE,
+                .len            = 16,
+                .sec            = -1,
+                .nsec           = 0,
+                .ret            = -1,
+                .err            = EINVAL,
+        },
+	{ // case10
+                .ttype          = EMPTY_QUEUE,
+                .len            = 16,
+                .sec            = 0,
+                .nsec           = -1,
+                .ret            = -1,
+                .err            = EINVAL,
+        },
+        { // case11
+                .ttype          = EMPTY_QUEUE,
+                .len            = 16,
+                .sec            = 0,
+                .nsec           = 1000000000,
+                .ret            = -1,
+                .err            = EINVAL,
+        },
+        { // case12
+                .ttype          = EMPTY_QUEUE,
+                .len            = 16,
+                .sec            = 0,
+                .nsec           = 999999999,
+                .ret            = -1,
+                .err            = ETIMEDOUT,
+        },
+        { // case13
+                .ttype          = SEND_SIGINT,
+                .len            = 16,
+                .ret            = -1,
+                .err            = EINTR,
+        },
+};
+
+
+
+
+#define MEM_LENGTH              (4 * 1024 * 1024)
+/*
+ * do_test()
+ *
+ *   Input  : TestCase Data
+ *   Return : RESULT_OK(0), RESULT_NG(1)
+ *
+ */
+
+static int do_test(struct test_case *tc)
+{
+        int sys_ret;
+        int sys_errno;
+        int result = RESULT_OK;
+	int oflag;
+        int i, rc, cmp_ok = 1, fd = -1;
+        char smsg[MAX_MSGSIZE], rmsg[MAX_MSGSIZE];
+        struct timespec ts, *p_ts;
+        pid_t pid = 0;
+        unsigned prio;
+        size_t msg_len;
+
+	/*
+         * When test ended with SIGTERM etc, mq discriptor is left remains.
+         * So we delete it first.
+         */
+        TEST(mq_unlink(QUEUE_NAME));
+
+switch (tc->ttype) {
+        case FD_NOT_EXIST:
+                fd = INT_MAX - 1;
+                /* fallthrough */
+        case FD_NONE:
+                break;
+        case FD_FILE:
+                TEST(fd = open("/", O_RDONLY));
+                if (TEST_RETURN < 0) {
+                 	tst_resm(TFAIL, "can't open \"/\". - errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        result = 1;
+                        goto EXIT;
+                }
+                break;
+        default:
+                /*
+                 * Open message queue
+                 */
+                oflag = O_CREAT|O_EXCL|O_RDWR;
+                if (tc->non_block)
+                        oflag |= O_NONBLOCK;
+
+                TEST(fd = mq_open(QUEUE_NAME, oflag, S_IRWXU, NULL));
+                if (TEST_RETURN < 0) {
+                 	tst_resm(TFAIL, "mq_open failed - errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        result = 1;
+                        goto EXIT;
+                }
+
+		 if (tc->ttype == SEND_SIGINT) {
+                        TEST(pid = create_sig_proc(200000, SIGINT));
+                        if (TEST_RETURN < 0) {
+                                result = 1;
+                                goto EXIT;
+                        }
+                }
+                break;
+           }
+
+	/*
+         * Prepare send message
+         */
+        for (i = 0; i < tc->len; i++)
+                smsg[i] = i;
+
+        /*
+         * Send message
+         */
+        switch (tc->ttype) {
+        case EMPTY_QUEUE:
+        case SEND_SIGINT:
+        case FD_NONE:
+        case FD_NOT_EXIST:
+        case FD_FILE:
+                break;
+        default:
+		TEST(rc = mq_timedsend(fd, smsg, tc->len, tc->prio, NULL));
+                if (TEST_RETURN < 0) {
+                 	tst_resm(TFAIL, "mq_timedsend failed - errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                        result = 1;
+                        goto EXIT;
+                }
+                break;
+        }
+
+        /*
+         * Set the message length and timeout value
+         */
+        msg_len = MAX_MSGSIZE;
+        if (tc->ttype == INVALID_MSG_LEN)
+                msg_len -= 1;
+        ts.tv_sec = tc->sec;
+        ts.tv_nsec = tc->nsec;
+        p_ts = &ts;
+        if (tc->sec == 0 && tc->nsec == 0)
+                p_ts = NULL;
+
+	/*
+         * Execute system call
+         */
+        errno = 0;
+        TEST(sys_ret = mq_timedreceive(fd, rmsg, msg_len, &prio, p_ts));
+        sys_errno = errno;
+        if (sys_ret < 0)
+                goto TEST_END;
+ 
+	 /*
+         * Compare received message
+         */
+        if (sys_ret != tc->len || tc->prio != prio)
+                cmp_ok = 0;
+        else {
+                for (i = 0; i < tc->len; i++)
+                        if (rmsg[i] != smsg[i]) {
+                                cmp_ok = 0;
+                                break;
+                        }
+        }
+
+
+	TEST_END:
+        /*
+         * Check results
+         */
+        result |= (sys_errno != tc->err) || !cmp_ok;
+        PRINT_RESULT_CMP(0, tc->ret == 0 ? tc->len : tc->ret, tc->err,sys_ret, sys_errno, cmp_ok);
+
+EXIT:
+        if (fd >= 0) {
+                TEST(close(fd));
+                TEST(mq_unlink(QUEUE_NAME));
+        }
+        if (pid > 0) {
+                int st;
+                TEST(kill(pid, SIGTERM));
+                TEST(wait(&st));
+        }
+        return result;
+}
+
+/*
+ * sighandler()
+ */
+void sighandler(int sig)
+{
+        if (sig == SIGINT)
+                return;
+        // NOTREACHED
+        return;
+}
+
+
+
+/*
+ * usage()
+ */
+
+static void usage(const char *progname)
+{
+        tst_resm(TINFO,"usage: %s [options]", progname);
+        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
+        tst_resm(TINFO,"options:");
+        tst_resm(TINFO,"    -d --debug           Show debug messages");
+        tst_resm(TINFO,"    -h --help            Show this message");
+        tst_resm(TINFO,"NG");
+        exit(1);
+}
+
+
+/*
+ * main()
+ */
+
+
+
+int main(int ac, char **av) {
+	int result = RESULT_OK;
+        int c;
+        int i;
+        int lc;                 /* loop counter */
+        char *msg;              /* message returned from parse_opts */
+
+	struct option long_options[] = {
+                { "debug", no_argument, 0, 'd' },
+                { "help",  no_argument, 0, 'h' },
+                { NULL, 0, NULL, 0 }
+        };
+
+	progname = strchr(av[0], '/');
+        progname = progname ? progname + 1 : av[0];	
+	
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
+
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
+			 while(TEST_RETURN != -1) {
+		                switch (c) {
+                		case 'd':
+		                        opt_debug = 1;
+                		        break;
+		                default:
+                		        usage(progname);
+                        		// NOTREACHED
+                		}
+		        }
+
+
+		if (ac != optind) {
+        	        tst_resm(TINFO,"Options are not match.");
+                	usage(progname);
+                	// NOTREACHED
+	        }
+
+		/*
+		* Execute test
+         	*/
+	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
+        	        int ret;
+	                tst_resm(TINFO,"(case%02d) START", i);
+	                ret = do_test(&tcase[i]);
+	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
+	                result |= ret;
+        	}
+		
+		/*
+        	 * Check results
+         	*/
+        	switch(result) {
+	        case RESULT_OK:
+        			tst_resm(TPASS, "mq_timedreceive call succeeded");
+		                break;
+
+	        default:
+                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
+        		        tst_resm(TINFO,"NG");
+				cleanup();
+				tst_exit();
+		                break;
+        	}
+
+                }
+        }	
+        cleanup();
+	tst_exit();
+}
+
--- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 13:28:26.000000000 +0530
+++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 13:27:56.000000000 +0530
@@ -587,6 +587,7 @@ mprotect03 mprotect03
 
 mq_notify01 mq_notify01
 mq_open01 mq_open01
+mq_timedreceive01 mq_timedreceive01
 
 mremap01 mremap01
 mremap02 mremap02

---
Regards--
Manas


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [LTP] [PATCH 09/13]  Add/Port utimes01 test for utimes() syscall
  2009-05-27 10:06 [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Manas Kumar Nayak
                   ` (7 preceding siblings ...)
  2009-05-27 10:10 ` [LTP] [PATCH 08/13] Add/Port mq_timedreceive01 test for mq_timedreceive() syscall Manas Kumar Nayak
@ 2009-05-27 10:11 ` Manas Kumar Nayak
  2009-05-29 12:56   ` Subrata Modak
  2009-05-27 10:11 ` [LTP] [PATCH 10/13] Add/Port mq_unlink01 test for mq_unlink() syscall Manas Kumar Nayak
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 31+ messages in thread
From: Manas Kumar Nayak @ 2009-05-27 10:11 UTC (permalink / raw)
  To: LTP List; +Cc: Manas Kumar Nayak

Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>
To: LTP List <ltp-list@lists.sourceforge.net>
Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
Cc: Masatake YAMATO <yamato@redhat.com>
---

--- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 13:31:15.000000000 +0530
+++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 13:39:18.000000000 +0530
@@ -1227,6 +1227,8 @@ utime04 utime04
 utime05 utime05
 utime06 utime06
 
+utimes01 utimes01
+
 # Introduced from Kernel 2.6.22 onwards
 utimensat01 utimensat_tests.sh
 
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/utimes/Makefile	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/utimes/Makefile	2009-05-23 14:53:58.000000000 +0530
@@ -0,0 +1,31 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2009
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+CFLAGS += -I../../../../include -Wall -O2
+LDLIBS += -L../../../../lib -lltp 
+
+SRCS    = $(wildcard *.c)
+TARGETS = $(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+
+clean:
+	rm -f $(TARGETS)
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/utimes/utimes01.c	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/utimes/utimes01.c	2009-05-27 13:33:45.000000000 +0530
@@ -0,0 +1,407 @@
+/******************************************************************************/
+/* Copyright (c) Crackerjack Project., 2007 ,Hitachi, Ltd                     */
+/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
+/*                                                                  	      */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
+/*                                                                            */
+/******************************************************************************/
+/******************************************************************************/
+/*                                                                            */
+/* File:        utimes01.c                                                    */
+/*                                                                            */
+/* Description: This tests the utimes() syscall                               */
+/*									      */
+/* 									      */
+/*									      */
+/*									      */
+/*									      */
+/*                                                                            */
+/* Usage:  <for command-line>                                                 */
+/* utimes01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                              */
+/*      where,  -c n : Run n copies concurrently.                             */
+/*              -e   : Turn on errno logging.                                 */
+/*              -i n : Execute test n times.                                  */
+/*              -I x : Execute test for x seconds.                            */
+/*              -P x : Pause for x seconds between iterations.                */
+/*              -t   : Turn on syscall timing.                                */
+/*                                                                            */
+/* Total Tests: 1                                                             */
+/*                                                                            */
+/* Test Name:   utimes01                                                      */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
+/******************************************************************************/
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
+#include <libgen.h>
+
+
+#include "../utils/include_j_h.h"
+#include "../utils/common_j_h.c"
+
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+#include "linux_syscall_numbers.h"
+
+/* Extern Global Variables */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "utimes01";  /* Test program identifier.*/
+int  testno;
+int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
+
+/* Extern Global Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    cleanup                                                       */
+/*                                                                            */
+/* Description: Performs all one time clean up for this test on successful    */
+/*              completion,  premature exit or  failure. Closes all temporary */
+/*              files, removes all temporary directories exits the test with  */
+/*              appropriate return code by calling tst_exit() function.       */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
+/*              On success - Exits calling tst_exit(). With '0' return code.  */
+/*                                                                            */
+/******************************************************************************/
+extern void cleanup() {
+        /* Remove tmp dir and all files in it */
+        TEST_CLEANUP;
+        tst_rmdir();
+
+        /* Exit with appropriate return code. */
+        tst_exit();
+}
+
+/* Local  Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    setup                                                         */
+/*                                                                            */
+/* Description: Performs all one time setup for this test. This function is   */
+/*              typically used to capture signals, create temporary dirs      */
+/*              and temporary files that may be used in the course of this    */
+/*              test.                                                         */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits by calling cleanup().                      */
+/*              On success - returns 0.                                       */
+/*                                                                            */
+/******************************************************************************/
+void setup() {
+        /* Capture signals if any */
+        /* Create temporary directories */
+        TEST_PAUSE;
+        tst_tmpdir();
+}
+
+
+/*
+ * Macros
+ */
+#define SYSCALL_NAME    "utimes"
+
+
+/*
+ * Global variables
+ */
+static int opt_debug;
+static char *progname;
+static char *progdir;
+
+enum test_type {
+		NORMAL,
+		FILE_NOT_EXIST,
+	        NO_FNAME,
+};
+
+
+/*
+ * Data Structure
+ */
+struct test_case {
+	int ttype;
+        long a_sec;
+        long m_sec;
+        char *user;
+        int ret;
+        int err;
+
+};
+
+
+/* Test cases
+ *
+ *   test status of errors on man page
+ *
+ *   EACCES             v (permission denied)
+ *   ENOENT             v (file does not exist)
+ *
+ *   test status of errors on man page
+ *
+ *   EFAULT             v (points to not process address space)
+ */
+
+static struct test_case tcase[] = {
+	{ // case00
+                .ttype          = NORMAL,
+                .a_sec          = 0,
+                .m_sec          = 1000,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case01
+                .ttype          = NORMAL,
+                .a_sec          = 1000,
+                .m_sec          = 0,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case02
+                .ttype          = NORMAL,
+                .a_sec          = 1000,
+                .m_sec          = 2000,
+                .user           = "nobody",
+                .ret            = -1,
+                .err            = EACCES, // RHEL4U1 + 2.6.18 returns EPERM
+        },
+        { // case03
+                .ttype          = FILE_NOT_EXIST,
+                .a_sec          = 1000,
+                .m_sec          = 2000,
+                .ret            = -1,
+                .err            = ENOENT,
+        },
+
+	{ // case04
+                .ttype          = NO_FNAME,
+                .a_sec          = 1000,
+                .m_sec          = 2000,
+                .ret            = -1,
+                .err            = EFAULT,
+        },
+};
+
+/*
+ * do_test()
+ *
+ *   Input  : TestCase Data
+ *   Return : RESULT_OK(0), RESULT_NG(1)
+ *
+ */
+
+static int do_test(struct test_case *tc)
+{
+        int sys_ret;
+        int sys_errno;
+        int result = RESULT_OK;
+	struct timeval tv[2];
+        char fpath[PATH_MAX], c = '\0';
+        int rc, len, cmp_ok = 1;
+        struct stat st;
+        uid_t old_uid;
+
+        TEST(rc = setup_file(progdir, "test.file", fpath));
+        if (rc < 0)
+                return 1;
+
+	/*
+         * Change effective user id
+         */
+        if (tc->user != NULL) {
+                TEST(rc = setup_euid(tc->user, &old_uid));
+                if (rc < 0)
+                        goto EXIT2;
+        }
+
+        /*
+         * Execute system call
+         */
+        tv[0].tv_sec = tc->a_sec;
+        tv[1].tv_sec = tc->m_sec;
+        TEST(len = strlen(fpath));
+        if (tc->ttype == FILE_NOT_EXIST) {
+                c = fpath[len - 1];
+                fpath[len - 1] = '\0';
+        }
+        errno = 0;
+        if (tc->ttype == NO_FNAME)
+                TEST(sys_ret = utimes(NULL, tv));
+        else
+                TEST(sys_ret = utimes(fpath, tv));
+        sys_errno = errno;
+        if (tc->ttype == FILE_NOT_EXIST)
+                fpath[len - 1] = c;
+        if (sys_ret < 0)
+                goto TEST_END;
+
+	/*
+         * Check test file's time stamp
+         */
+        rc = stat(fpath, &st);
+        if (rc < 0) {
+                EPRINTF("stat failed.\n");
+                result = 1;
+                goto EXIT1;
+        }
+        tst_resm(TINFO,"E:%ld,%ld <=> R:%ld,%ld",tv[0].tv_sec, tv[1].tv_sec, st.st_atime, st.st_mtime);
+        cmp_ok = st.st_atime == tv[0].tv_sec && st.st_mtime == tv[1].tv_sec;
+
+        /*
+         * Check results
+         */
+TEST_END:
+        result |= (sys_errno != tc->err) || !cmp_ok;
+        PRINT_RESULT_CMP(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno,cmp_ok);
+
+        /*
+         * Restore effective user id
+         */
+EXIT1:
+        if (tc->user != NULL) {
+                TEST(rc = cleanup_euid(old_uid));
+                if (rc < 0)
+                        return 1;
+        }
+EXIT2:
+        TEST(cleanup_file(fpath));
+
+        return result;
+}
+
+/*
+ * usage()
+ */
+
+static void usage(const char *progname)
+{
+        tst_resm(TINFO,"usage: %s [options]", progname);
+        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
+        tst_resm(TINFO,"options:");
+        tst_resm(TINFO,"    -d --debug           Show debug messages");
+        tst_resm(TINFO,"    -h --help            Show this message");
+        tst_resm(TINFO,"NG");
+        exit(1);
+}
+
+
+/*
+ * main()
+ */
+
+
+
+int main(int ac, char **av) {
+	int result = RESULT_OK;
+        int c;
+        int i;
+        int lc;                 /* loop counter */
+        char *msg;              /* message returned from parse_opts */
+
+	struct option long_options[] = {
+                { "debug", no_argument, 0, 'd' },
+                { "help",  no_argument, 0, 'h' },
+                { NULL, 0, NULL, 0 }
+        };
+
+	progname = strchr(av[0], '/');
+        progname = progname ? progname + 1 : av[0];	
+	
+	progdir = strdup(av[0]);
+        progdir = dirname(progdir);
+	
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
+
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
+			 while(TEST_RETURN != -1) {
+		                switch (c) {
+                		case 'd':
+		                        opt_debug = 1;
+                		        break;
+		                default:
+                		        usage(progname);
+                        		// NOTREACHED
+                		}
+		        }
+
+
+		if (ac != optind) {
+        	        tst_resm(TINFO,"Options are not match.");
+                	usage(progname);
+                	// NOTREACHED
+	        }
+
+		/*
+		* Execute test
+         	*/
+	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
+        	        int ret;
+	                tst_resm(TINFO,"(case%02d) START", i);
+	                ret = do_test(&tcase[i]);
+	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
+	                result |= ret;
+        	}
+		
+		/*
+        	 * Check results
+         	*/
+        	switch(result) {
+	        case RESULT_OK:
+        			tst_resm(TPASS, "utimes call succeeded ");
+		                break;
+
+	        default:
+                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
+        		        tst_resm(TINFO,"NG");
+				cleanup();
+				tst_exit();
+		                break;
+        	}
+
+                }
+        }	
+        cleanup();
+	tst_exit();
+}
+

---
Regards--
Manas


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [LTP] [PATCH 10/13] Add/Port mq_unlink01 test for mq_unlink() syscall
  2009-05-27 10:06 [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Manas Kumar Nayak
                   ` (8 preceding siblings ...)
  2009-05-27 10:11 ` [LTP] [PATCH 09/13] Add/Port utimes01 test for utimes() syscall Manas Kumar Nayak
@ 2009-05-27 10:11 ` Manas Kumar Nayak
  2009-05-29 12:56   ` Subrata Modak
  2009-05-27 10:12 ` [LTP] [PATCH 11/13] Add/Port mq_timedsend01 test for mq_timedsend() syscall Manas Kumar Nayak
                   ` (3 subsequent siblings)
  13 siblings, 1 reply; 31+ messages in thread
From: Manas Kumar Nayak @ 2009-05-27 10:11 UTC (permalink / raw)
  To: LTP List; +Cc: Manas Kumar Nayak

Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>
To: LTP List <ltp-list@lists.sourceforge.net>
Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
Cc: Masatake YAMATO <yamato@redhat.com>
---

--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_unlink/Makefile	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_unlink/Makefile	2009-05-23 14:56:20.000000000 +0530
@@ -0,0 +1,31 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2009
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+CFLAGS += -I../../../../include -Wall -O2
+LDLIBS += -L../../../../lib -lltp -lrt
+
+SRCS    = $(wildcard *.c)
+TARGETS = $(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+
+clean:
+	rm -f $(TARGETS)
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_unlink/mq_unlink01.c	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_unlink/mq_unlink01.c	2009-05-27 13:51:14.000000000 +0530
@@ -0,0 +1,392 @@
+/******************************************************************************/
+/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
+/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
+/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
+/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
+/*                                                                  	      */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
+/*                                                                            */
+/******************************************************************************/
+/******************************************************************************/
+/*                                                                            */
+/* File:        mq_ulink01.c                                                  */
+/*                                                                            */
+/* Description: This tests the mq_ulink() syscall                             */
+/*									      */
+/* 									      */
+/*									      */
+/*									      */
+/*									      */
+/*                                                                            */
+/* Usage:  <for command-line>                                                 */
+/* mq_ulink01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                            */
+/*      where,  -c n : Run n copies concurrently.                             */
+/*              -e   : Turn on errno logging.                                 */
+/*              -i n : Execute test n times.                                  */
+/*              -I x : Execute test for x seconds.                            */
+/*              -P x : Pause for x seconds between iterations.                */
+/*              -t   : Turn on syscall timing.                                */
+/*                                                                            */
+/* Total Tests: 1                                                             */
+/*                                                                            */
+/* Test Name:   mq_ulink01                                             */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
+/******************************************************************************/
+
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/uio.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <mqueue.h>
+#include <limits.h>
+
+
+#include "../utils/include_j_h.h"
+#include "../utils/common_j_h.c"
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+#include "linux_syscall_numbers.h"
+
+/* Extern Global Variables */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "mq_ulink01";  /* Test program identifier.*/
+int  testno;
+int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
+
+/* Extern Global Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    cleanup                                                       */
+/*                                                                            */
+/* Description: Performs all one time clean up for this test on successful    */
+/*              completion,  premature exit or  failure. Closes all temporary */
+/*              files, removes all temporary directories exits the test with  */
+/*              appropriate return code by calling tst_exit() function.       */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
+/*              On success - Exits calling tst_exit(). With '0' return code.  */
+/*                                                                            */
+/******************************************************************************/
+extern void cleanup() {
+        /* Remove tmp dir and all files in it */
+        TEST_CLEANUP;
+        tst_rmdir();
+
+        /* Exit with appropriate return code. */
+        tst_exit();
+}
+
+/* Local  Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    setup                                                         */
+/*                                                                            */
+/* Description: Performs all one time setup for this test. This function is   */
+/*              typically used to capture signals, create temporary dirs      */
+/*              and temporary files that may be used in the course of this    */
+/*              test.                                                         */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits by calling cleanup().                      */
+/*              On success - returns 0.                                       */
+/*                                                                            */
+/******************************************************************************/
+void setup() {
+        /* Capture signals if any */
+        /* Create temporary directories */
+        TEST_PAUSE;
+        tst_tmpdir();
+}
+
+
+/*
+ * Macros
+ */
+#define SYSCALL_NAME    "mq_ulink"
+
+
+/*
+ * Global variables
+ */
+static int opt_debug;
+static char *progname;
+
+enum test_type {
+		NORMAL,
+};
+
+
+/*
+ * Data Structure
+ */
+struct test_case {
+	char *user;
+        char *qname;
+        int ttype;
+        int ret;
+        int err;
+};
+
+
+/* Test cases
+*
+*   test status of errors on man page
+*
+*   EACCES             v (permission is denied)
+*   ENAMETOOLONG       v (too long name length)
+*   ENOENT             v (named message queue does not exist)
+*/
+
+static struct test_case tcase[] = {
+	{ // case00
+                .ttype          = NORMAL,
+                .qname          = QUEUE_NAME,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case01
+                .ttype          = NORMAL,
+                .user           = "nobody",
+                .qname          = QUEUE_NAME,
+                .ret            = -1,
+                .err            = EACCES,
+        },
+        { // case02
+                .ttype          = NORMAL,
+                                //  0         1         2         3
+                                //  0123456789012345678901234567890123456789
+                .qname          = "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaa",
+                .ret            = -1,
+                .err            = ENOENT,
+        },
+	{ // case03
+                .ttype          = NORMAL,
+                                //  0         1         2         3
+                                //  0123456789012345678901234567890123456789
+                .qname          = "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+                                   "aaaaaaaaaaaaaaaa",
+                .ret            = -1,
+                .err            = ENAMETOOLONG,
+        },
+};
+
+/*
+ * do_test()
+ *
+ *   Input  : TestCase Data
+ *   Return : RESULT_OK(0), RESULT_NG(1)
+ *
+ */
+
+static int do_test(struct test_case *tc)
+{
+        int sys_ret;
+        int sys_errno;
+        int result = RESULT_OK;
+	int rc, fd1 = -1, fd2 = -1;
+        uid_t old_uid = -1;
+
+        /*
+         * When test ended with SIGTERM etc, mq discriptor is left remains.
+         * So we delete it first.
+         */
+        TEST(mq_unlink(QUEUE_NAME));
+
+        /*
+         * Open message queue
+         */
+        TEST(rc = mq_open(QUEUE_NAME, O_CREAT|O_EXCL|O_RDWR, S_IRWXU, NULL));
+	if (TEST_RETURN < 0) {
+                tst_resm(TFAIL, "mq_open failed - errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+                result = 1;
+                goto EXIT;
+        }
+        fd1 = rc;
+
+        /*
+         * Change effective user id
+         */
+        if (tc->user != NULL) {
+                TEST(rc = setup_euid(tc->user, &old_uid));
+                if (TEST_RETURN < 0) {
+                        result = 1;
+                        goto EXIT;
+                }
+        }
+
+/*
+         * Execute system call
+         */
+        //tst_resm(TINFO,"PATH_MAX: %d\n", PATH_MAX);
+        //tst_resm(TINFO,"NAME_MAX: %d\n", NAME_MAX);
+        errno = 0;
+        TEST(sys_ret = mq_unlink(tc->qname));
+        sys_errno = errno;
+        if (sys_ret >= 0)
+                fd2 = sys_ret;
+
+        /*
+         * Check results
+         */
+        result |= (sys_errno != tc->err);
+        PRINT_RESULT(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno);
+
+EXIT:
+        if (tc->user != NULL && old_uid != -1)
+                cleanup_euid(old_uid);
+
+        if (fd1 >= 0)
+                close(fd1);
+        if (fd2 >= 0)
+                close(fd2);
+        if (fd1 >= 0)
+                mq_unlink(QUEUE_NAME);
+
+        return result;
+}
+
+
+/*
+ * usage()
+ */
+
+static void usage(const char *progname)
+{
+        tst_resm(TINFO,"usage: %s [options]", progname);
+        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
+        tst_resm(TINFO,"options:");
+        tst_resm(TINFO,"    -d --debug           Show debug messages");
+        tst_resm(TINFO,"    -h --help            Show this message");
+        tst_resm(TINFO,"NG\n");
+        exit(1);
+}
+
+
+/*
+ * main()
+ */
+
+
+
+int main(int ac, char **av) {
+	int result = RESULT_OK;
+        int c;
+        int i;
+        int lc;                 /* loop counter */
+        char *msg;              /* message returned from parse_opts */
+
+	struct option long_options[] = {
+                { "debug", no_argument, 0, 'd' },
+                { "help",  no_argument, 0, 'h' },
+                { NULL, 0, NULL, 0 }
+        };
+
+	progname = strchr(av[0], '/');
+        progname = progname ? progname + 1 : av[0];	
+	
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
+
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
+			 while(TEST_RETURN != -1) {
+		                switch (c) {
+                		case 'd':
+		                        opt_debug = 1;
+                		        break;
+		                default:
+                		        usage(progname);
+                        		// NOTREACHED
+                		}
+		        }
+
+
+		if (ac != optind) {
+        	        tst_resm(TINFO,"Options are not match.");
+                	usage(progname);
+                	// NOTREACHED
+	        }
+
+		/*
+		* Execute test
+         	*/
+	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
+        	        int ret;
+	                tst_resm(TINFO,"(case%02d) START", i);
+	                ret = do_test(&tcase[i]);
+	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
+	                result |= ret;
+        	}
+		
+		/*
+        	 * Check results
+         	*/
+        	switch(result) {
+	        case RESULT_OK:
+        			tst_resm(TPASS, "mq_ulink call succeeded");
+		                break;
+
+	        default:
+                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
+        		        RPRINTF("NG\n");
+				cleanup();
+				tst_exit();
+		                break;
+        	}
+
+                }
+        }	
+        cleanup();
+	tst_exit();
+}
+
--- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 13:43:32.000000000 +0530
+++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 13:52:49.000000000 +0530
@@ -588,6 +588,7 @@ mprotect03 mprotect03
 mq_notify01 mq_notify01
 mq_open01 mq_open01
 mq_timedreceive01 mq_timedreceive01
+mq_unlink01 mq_unlink01
 
 mremap01 mremap01
 mremap02 mremap02

---
Regards--
Manas


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [LTP] [PATCH 11/13] Add/Port mq_timedsend01 test for mq_timedsend() syscall
  2009-05-27 10:06 [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Manas Kumar Nayak
                   ` (9 preceding siblings ...)
  2009-05-27 10:11 ` [LTP] [PATCH 10/13] Add/Port mq_unlink01 test for mq_unlink() syscall Manas Kumar Nayak
@ 2009-05-27 10:12 ` Manas Kumar Nayak
  2009-05-29 12:57   ` Subrata Modak
  2009-05-27 10:12 ` [LTP] [PATCH 12/13] Add/Port unshare01 test for unshare() syscall Manas Kumar Nayak
                   ` (2 subsequent siblings)
  13 siblings, 1 reply; 31+ messages in thread
From: Manas Kumar Nayak @ 2009-05-27 10:12 UTC (permalink / raw)
  To: LTP List; +Cc: Manas Kumar Nayak

Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>
To: LTP List <ltp-list@lists.sourceforge.net>
Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
Cc: Masatake YAMATO <yamato@redhat.com>
---

--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_timedsend/Makefile	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_timedsend/Makefile	2009-05-23 15:08:59.000000000 +0530
@@ -0,0 +1,31 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2009
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+CFLAGS += -I../../../../include -Wall -O2
+LDLIBS += -L../../../../lib -lltp -lrt
+
+SRCS    = $(wildcard *.c)
+TARGETS = $(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+
+clean:
+	rm -f $(TARGETS)
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c	2009-05-27 14:11:33.000000000 +0530
@@ -0,0 +1,539 @@
+/******************************************************************************/
+/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
+/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
+/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
+/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
+/*                                                                  	      */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
+/*                                                                            */
+/******************************************************************************/
+/******************************************************************************/
+/*                                                                            */
+/* File:        mq_timedsend01.c                                              */
+/*                                                                            */
+/* Description: This tests the mq_timedsend() syscall                         */
+/*									      */
+/* 									      */
+/*									      */
+/*									      */
+/*									      */
+/*                                                                            */
+/* Usage:  <for command-line>                                                 */
+/* mq_timedsend01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                        */
+/*      where,  -c n : Run n copies concurrently.                             */
+/*              -e   : Turn on errno logging.                                 */
+/*              -i n : Execute test n times.                                  */
+/*              -I x : Execute test for x seconds.                            */
+/*              -P x : Pause for x seconds between iterations.                */
+/*              -t   : Turn on syscall timing.                                */
+/*                                                                            */
+/* Total Tests: 1                                                             */
+/*                                                                            */
+/* Test Name:   mq_timedsend01                                                */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
+/******************************************************************************/
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <mqueue.h>
+#include <time.h>
+#include <signal.h>
+#include <limits.h>
+
+
+#include "../utils/include_j_h.h"
+#include "../utils/common_j_h.c"
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+#include "linux_syscall_numbers.h"
+
+/* Extern Global Variables */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "mq_timedsend01";  /* Test program identifier.*/
+int  testno;
+int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
+
+/* Extern Global Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    cleanup                                                       */
+/*                                                                            */
+/* Description: Performs all one time clean up for this test on successful    */
+/*              completion,  premature exit or  failure. Closes all temporary */
+/*              files, removes all temporary directories exits the test with  */
+/*              appropriate return code by calling tst_exit() function.       */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
+/*              On success - Exits calling tst_exit(). With '0' return code.  */
+/*                                                                            */
+/******************************************************************************/
+extern void cleanup() {
+        /* Remove tmp dir and all files in it */
+        TEST_CLEANUP;
+        tst_rmdir();
+
+        /* Exit with appropriate return code. */
+        tst_exit();
+}
+
+/* Local  Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    setup                                                         */
+/*                                                                            */
+/* Description: Performs all one time setup for this test. This function is   */
+/*              typically used to capture signals, create temporary dirs      */
+/*              and temporary files that may be used in the course of this    */
+/*              test.                                                         */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits by calling cleanup().                      */
+/*              On success - returns 0.                                       */
+/*                                                                            */
+/******************************************************************************/
+void setup() {
+        /* Capture signals if any */
+        /* Create temporary directories */
+        TEST_PAUSE;
+        tst_tmpdir();
+}
+
+
+/*
+ * Macros
+ */
+#define SYSCALL_NAME    "mq_timedsend"
+
+
+/*
+ * Global variables
+ */
+static int opt_debug;
+static char *progname;
+
+enum test_type {
+		NORMAL,
+		FD_NONE,
+	        FD_NOT_EXIST,
+        	FD_FILE,
+	        FULL_QUEUE,
+        	SEND_SIGINT,
+};
+
+/*
+ * Data Structure
+ */
+struct test_case {
+	int ttype;
+        int non_block;
+        int len;
+        unsigned prio;
+        time_t sec;
+        long nsec;
+        int ret;
+        int err;
+};
+
+#define MAX_MSG         10
+#define MAX_MSGSIZE     8192
+
+/* Test cases
+*
+*   test status of errors on man page
+*
+*   EAGAIN             v (would block)
+*   EBADF              v (not a valid descriptor)
+*   EINTR              v (interrupted by a signal)
+*   EINVAL             v (1. invalid 'msg_prio' or
+*                         2. would block but timeout exists)
+*   EMSGSIZE           v ('msg_len' exceeds the message size of the queue)
+*   ETIMEDOUT          v (not block and timeout occured)
+*/
+
+static struct test_case tcase[] = {
+	{ // case00
+                .ttype          = NORMAL,
+                .len            = 0,    // also success when size equals zero
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case01
+                .ttype          = NORMAL,
+                .len            = 1,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case02
+                .ttype          = NORMAL,
+                .len            = MAX_MSGSIZE,
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case03
+                .ttype          = NORMAL,
+                .len            = 1,
+                .prio           = 32767, // max priority
+                .ret            = 0,
+                .err            = 0,
+        },
+        { // case04
+                .ttype          = NORMAL,
+                .len            = MAX_MSGSIZE + 1,
+                .ret            = -1,
+                .err            = EMSGSIZE,
+        },
+	{ // case05
+                .ttype          = FD_NONE,
+                .len            = 0,
+                .ret            = -1,
+                .err            = EBADF,
+        },
+        { // case06
+                .ttype          = FD_NOT_EXIST,
+                .len            = 0,
+                .ret            = -1,
+                .err            = EBADF,
+        },
+        { // case07
+                .ttype          = FD_FILE,
+                .len            = 0,
+                .ret            = -1,
+                .err            = EBADF,
+        },
+        { // case08
+                .ttype          = FULL_QUEUE,
+                .non_block      = 1,
+                .len            = 16,
+                .ret            = -1,
+                .err            = EAGAIN,
+        },
+	{ // case09
+                .ttype          = NORMAL,
+                .len            = 1,
+                .prio           = 32768, // max priority + 1
+                .ret            = -1,
+                .err            = EINVAL,
+        },
+        { // case10
+                .ttype          = FULL_QUEUE,
+                .len            = 16,
+                .sec            = -1,
+                .nsec           = 0,
+                .ret            = -1,
+                .err            = EINVAL,
+        },
+        { // case11
+                .ttype          = FULL_QUEUE,
+                .len            = 16,
+                .sec            = 0,
+                .nsec           = -1,
+                .ret            = -1,
+                .err            = EINVAL,
+        },
+        { // case12
+                .ttype          = FULL_QUEUE,
+                .len            = 16,
+                .sec            = 0,
+                .nsec           = 1000000000,
+                .ret            = -1,
+                .err            = EINVAL,
+        },
+	{ // case13
+                .ttype          = FULL_QUEUE,
+                .len            = 16,
+                .sec            = 0,
+                .nsec           = 999999999,
+                .ret            = -1,
+                .err            = ETIMEDOUT,
+        },
+        { // case14
+                .ttype          = SEND_SIGINT,
+                .len            = 16,
+                .ret            = -1,
+                .err            = EINTR,
+        },
+};
+
+
+/*
+ * do_test()
+ *
+ *   Input  : TestCase Data
+ *   Return : RESULT_OK(0), RESULT_NG(1)
+ *
+ */
+
+static int do_test(struct test_case *tc)
+{
+        int sys_ret;
+        int sys_errno;
+        int result = RESULT_OK;
+	int oflag;
+        int i, rc, cmp_ok = 1, fd = -1;
+        char smsg[MAX_MSGSIZE], rmsg[MAX_MSGSIZE];
+        struct timespec ts, *p_ts;
+        pid_t pid = 0;
+        unsigned prio;
+
+        /*
+         * When test ended with SIGTERM etc, mq discriptor is left remains.
+         * So we delete it first.
+         */
+        TEST(mq_unlink(QUEUE_NAME));
+
+        switch (tc->ttype) {
+        case FD_NOT_EXIST:
+                fd = INT_MAX - 1;
+                /* fallthrough */
+        case FD_NONE:
+                break;
+	case FD_FILE:
+                TEST(fd = open("/", O_RDONLY));
+                if (fd < 0) {
+                 	tst_resm(TFAIL, "can't open \"/\".- errno = %d : %s\n", TEST_ERRNO, strerror(TEST_ERRNO));
+                        result = 1;
+                        goto EXIT;
+                }
+                break;
+        default:
+                /*
+                 * Open message queue
+                 */
+                oflag = O_CREAT|O_EXCL|O_RDWR;
+                if (tc->non_block)
+                        oflag |= O_NONBLOCK;
+
+                TEST(fd = mq_open(QUEUE_NAME, oflag, S_IRWXU, NULL));
+                if (TEST_RETURN < 0) {
+                 	tst_resm(TFAIL, "mq_open failed - errno = %d : %s\n", TEST_ERRNO, strerror(TEST_ERRNO));
+                        result = 1;
+                        goto EXIT;
+                }
+                if (tc->ttype == FULL_QUEUE || tc->ttype == SEND_SIGINT) {
+                        for (i = 0; i < MAX_MSG; i++) {
+                                TEST(rc = mq_timedsend(fd, smsg, tc->len, 0, NULL));
+                                if (rc < 0) {
+                 	   		tst_resm(TFAIL, "mq_timedsend failed - errno = %d : %s\n",TEST_ERRNO, strerror(TEST_ERRNO));
+                                        result = 1;
+                                        goto EXIT;
+                                }
+                        }
+			if (tc->ttype == SEND_SIGINT) {
+                                TEST(pid = create_sig_proc(200000, SIGINT));
+                                if (TEST_RETURN < 0) {
+                                        result = 1;
+                                        goto EXIT;
+                                }
+                        }
+                }
+                break;
+        }
+
+        /*
+         * Prepare send message
+         */
+        for (i = 0; i < tc->len; i++)
+                smsg[i] = i;
+
+        /*
+         * Set the timeout value
+         */
+        ts.tv_sec = tc->sec;
+        ts.tv_nsec = tc->nsec;
+        p_ts = &ts;
+        if (tc->sec == 0 && tc->nsec == 0)
+                p_ts = NULL;
+
+        /*
+        * Execut test system call
+         */
+        errno = 0;
+        TEST(sys_ret = mq_timedsend(fd, smsg, tc->len, tc->prio, p_ts));
+        sys_errno = errno;
+        if (sys_ret < 0)
+                goto TEST_END;
+
+        /*
+         * Receive echoed message and compare
+         */
+        TEST(rc = mq_timedreceive(fd, rmsg, MAX_MSGSIZE, &prio, NULL));
+        if (rc < 0) {
+                tst_resm(TFAIL, "mq_timedreceive failed - errno = %d : %s\n",TEST_ERRNO, strerror(TEST_ERRNO));
+                result = 1;
+                goto EXIT;
+        }
+        if (rc != tc->len || tc->prio != prio)
+                cmp_ok = 0;
+        else {
+                for (i = 0; i < tc->len; i++)
+                        if (rmsg[i] != smsg[i]) {
+                                cmp_ok = 0;
+                                break;
+                        }
+        }
+TEST_END:
+        /*
+         * Check results
+         */
+        result |= (sys_errno != tc->err) || !cmp_ok;
+        PRINT_RESULT_CMP(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno,cmp_ok);
+
+EXIT:
+        if (fd >= 0) {
+                TEST(close(fd));
+                TEST(mq_unlink(QUEUE_NAME));
+        }
+        if (pid > 0) {
+                int st;
+                kill(pid, SIGTERM);
+                wait(&st);
+        }
+        exit(result);
+}
+
+
+/*
+ * sighandler()
+ */
+void sighandler(int sig)
+{
+        if (sig == SIGINT)
+                return;
+        // NOTREACHED
+        return;
+}
+
+
+/*
+ * usage()
+ */
+
+static void usage(const char *progname)
+{
+        tst_resm(TINFO,"usage: %s [options]\n", progname);
+        tst_resm(TINFO,"This is a regression test program of %s system call.\n",SYSCALL_NAME);
+        tst_resm(TINFO,"options:\n");
+        tst_resm(TINFO,"    -d --debug           Show debug messages\n");
+        tst_resm(TINFO,"    -h --help            Show this message\n");
+        tst_resm(TINFO,"NG\n");
+        exit(1);
+}
+
+
+/*
+ * main()
+ */
+
+
+
+int main(int ac, char **av) {
+	int result = RESULT_OK;
+        int c;
+        int i;
+        int lc;                 /* loop counter */
+        char *msg;              /* message returned from parse_opts */
+
+	struct option long_options[] = {
+                { "debug", no_argument, 0, 'd' },
+                { "help",  no_argument, 0, 'h' },
+                { NULL, 0, NULL, 0 }
+        };
+
+	progname = strchr(av[0], '/');
+        progname = progname ? progname + 1 : av[0];	
+	
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
+
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
+			 while(TEST_RETURN != -1) {
+		                switch (c) {
+                		case 'd':
+		                        opt_debug = 1;
+                		        break;
+		                default:
+                		        usage(progname);
+                        		// NOTREACHED
+                		}
+		        }
+
+
+		if (ac != optind) {
+        	        tst_resm(TINFO,"Options are not match.");
+                	usage(progname);
+                	// NOTREACHED
+	        }
+		/*
+        	 * Execute test
+        	 */
+        	signal(SIGINT, sighandler);
+
+	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
+        	        int ret;
+	                tst_resm(TINFO,"(case%02d) START", i);
+	                ret = do_test(&tcase[i]);
+	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
+	                result |= ret;
+        	}
+		/*	
+        	 * Check results
+         	*/
+        	switch(result) {
+	        case RESULT_OK:
+        			tst_resm(TPASS, "mq_timedsend call succeeded");
+		                break;
+
+	        default:
+                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
+        		        RPRINTF("NG\n");
+				cleanup();
+				tst_exit();
+        	}
+
+                }
+        }	
+        cleanup();
+	tst_exit();
+}
+
--- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 13:55:49.000000000 +0530
+++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 14:13:17.000000000 +0530
@@ -588,6 +588,7 @@ mprotect03 mprotect03
 mq_notify01 mq_notify01
 mq_open01 mq_open01
 mq_timedreceive01 mq_timedreceive01
+mq_timedsend01 mq_timedsend01
 mq_unlink01 mq_unlink01
 
 mremap01 mremap01

---
Regards--
Manas


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [LTP] [PATCH 12/13] Add/Port unshare01 test for unshare() syscall
  2009-05-27 10:06 [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Manas Kumar Nayak
                   ` (10 preceding siblings ...)
  2009-05-27 10:12 ` [LTP] [PATCH 11/13] Add/Port mq_timedsend01 test for mq_timedsend() syscall Manas Kumar Nayak
@ 2009-05-27 10:12 ` Manas Kumar Nayak
  2009-05-29 12:57   ` Subrata Modak
  2009-05-27 10:13 ` [LTP] [PATCH 13/13] Add/Port unshare02 " Manas Kumar Nayak
  2009-05-29 12:55 ` [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Subrata Modak
  13 siblings, 1 reply; 31+ messages in thread
From: Manas Kumar Nayak @ 2009-05-27 10:12 UTC (permalink / raw)
  To: LTP List; +Cc: Manas Kumar Nayak

Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>
To: LTP List <ltp-list@lists.sourceforge.net>
Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
Cc: Masatake YAMATO <yamato@redhat.com>
---

--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/unshare/Makefile	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/unshare/Makefile	2009-05-25 15:12:47.000000000 +0530
@@ -0,0 +1,31 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2009
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+CFLAGS += -I../../../../include -Wall
+LDLIBS += -L../../../../lib -lltp
+
+SRCS    = $(wildcard *.c)
+TARGETS = $(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+
+clean:
+	rm -f $(TARGETS)
--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/unshare/unshare01.c	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/unshare/unshare01.c	2009-05-27 14:43:04.000000000 +0530
@@ -0,0 +1,231 @@
+/********************************************************************************/
+/* Copyright (c) Crackerjack Project., 2007                                   	*/
+/*                                                                            	*/
+/* This program is free software;  you can redistribute it and/or modify      	*/
+/* it under the terms of the GNU General Public License as published by       	*/
+/* the Free Software Foundation; either version 2 of the License, or          	*/
+/* (at your option) any later version.                                        	*/
+/*                                                                            	*/
+/* This program is distributed in the hope that it will be useful,            	*/
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            	*/
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  	*/
+/* the GNU General Public License for more details.                           	*/
+/*                                                                            	*/
+/* You should have received a copy of the GNU General Public License          	*/
+/* along with this program;  if not, write to the Free Software               	*/
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    	*/
+/*                                                                            	*/
+/******************************************************************************	*/
+/******************************************************************************	*/
+/*                                                                            	*/
+/* File:        unshare01.c                                           	      	*/
+/*                                                                            	*/
+/* Description: This tests the unshare() syscall.                      	      	*/
+/*             unshare() allows a process to disassociate parts of its 		*/
+/*		execution context that are currently being shared with other 	*/
+/*		processes. Part of the execution context, such as the namespace	*/
+/*		,is shared implicitly when a new process is created using 	*/
+/*		fork(2) or vfork(2), while other parts, such as virtual memory	*/
+/*		, may be shared by explicit request when creating a process 	*/
+/*		using clone(2).							*/
+/*										*/
+/*		The main use of unshare() is to allow a process to control its	*/ 
+/*		shared execution context without creating a new process.	*/
+/*	         								*/
+/*										*/
+/*		The flags argument is a bit mask that specifies which parts of	*/
+/*		the execution context should be unshared. This argument is 	*/
+/*		specified by ORing together zero or more of the following cons-	*/
+/*		tants:								*/
+/*										*/
+/*		CLONE_FILES:							*/
+/*		    	Reverse the effect of the clone(2) CLONE_FILES flag. 	*/
+/*			Unshare	the file descriptor table, so that the calling 	*/
+/*			process no longer shares its file descriptors with any 	*/
+/*			other process.						*/
+/*		CLONE_FS:							*/
+/*			Reverse the effect of the clone(2) CLONE_FS flag.Unshare*/
+/*			file system attributes, so that the calling process no 	*/
+/*			longer shares its root directory, current directory, or	*/
+/*			umask attributes with any other process.		*/
+/*		CLONE_NEWNS:							*/
+/*		       This flag has the same effect as the clone(2) CLONE_NEWNS*/ 
+/*			flag. Unshare the namespace, so that the calling process*/ 
+/*			has a private copy of its namespacei which is not shared*/
+/*			with any other process. Specifying this flag automat-	*/
+/*			ically implies CLONE_FS as well. 			*/
+/*										*/
+/*		If flags is specified as zero, then unshare() is a no-op; no 	*/
+/*		changes are made to the calling process's execution context. 	*/
+/*		                                                               	*/
+/* Usage:  <for command-line>                                                 	*/
+/* unshare01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                     		*/
+/*      where,  -c n : Run n copies concurrently.                             	*/
+/*              -e   : Turn on errno logging.                                 	*/
+/*              -i n : Execute test n times.                                  	*/
+/*              -I x : Execute test for x seconds.                            	*/
+/*              -P x : Pause for x seconds between iterations.                	*/
+/*              -t   : Turn on syscall timing.                                	*/
+/*                                                                            	*/
+/* Total Tests: 1                                                             	*/
+/*                                                                            	*/
+/* Test Name:   unshare01                                             		*/
+/* History:     Porting from Crackerjack to LTP is done by                    	*/
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        	*/
+/********************************************************************************/
+
+#include <stdio.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <sched.h>
+#include <limits.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <errno.h>
+#include <pwd.h>
+#include <grp.h>
+#include <string.h>
+#include <sys/param.h>
+#include <stdio.h>
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+#include "linux_syscall_numbers.h"
+
+/* Extern Global Variables */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "unshare01";  /* Test program identifier.*/
+int  testno;
+int  TST_TOTAL =1;                   /* total number of tests in this file.   */
+
+/* Extern Global Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    cleanup                                                       */
+/*                                                                            */
+/* Description: Performs all one time clean up for this test on successful    */
+/*              completion,  premature exit or  failure. Closes all temporary */
+/*              files, removes all temporary directories exits the test with  */
+/*              appropriate TEST_RETURNurn code by calling tst_exit() function.       */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits calling tst_exit(). Non '0' TEST_RETURNurn code.   */
+/*              On success - Exits calling tst_exit(). With '0' TEST_RETURNurn code.  */
+/*                                                                            */
+/******************************************************************************/
+extern void cleanup() {
+        /* Remove tmp dir and all files in it */
+        TEST_CLEANUP;
+        tst_rmdir();
+
+        /* Exit with appropriate TEST_RETURNurn code. */
+        tst_exit();
+}
+
+/* Local  Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    setup                                                         */
+/*                                                                            */
+/* Description: Performs all one time setup for this test. This function is   */
+/*              typically used to capture signals, create temporary dirs      */
+/*              and temporary files that may be used in the course of this    */
+/*              test.                                                         */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits by calling cleanup().                      */
+/*              On success - TEST_RETURNurns 0.                                       */
+/*                                                                            */
+/******************************************************************************/
+void setup() {
+        /* Capture signals if any */
+        /* Create temporary directories */
+        TEST_PAUSE;
+        tst_tmpdir();
+}
+
+int main(int ac, char **av) {
+        pid_t pid1;
+	int lc;                 /* loop counter */
+        char *msg;              /* message TEST_RETURNurned from parse_opts */
+	
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
+
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+
+ /*
+ *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));
+				cleanup();
+				tst_exit();
+			}else if (TEST_RETURN == 0){
+				if((TEST_RETURN = unshare(CLONE_FILES)) == 0) {
+	        		tst_resm(TPASS, "unshare with CLONE_FILES call succeeded");
+				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));
+	                        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{
+			}
+
+			TEST(pid1=fork());    //call to fork()
+                        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{
+			}
+
+
+                }
+
+                }
+	cleanup();
+	tst_exit();
+}
+
--- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 14:45:49.000000000 +0530
+++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 14:45:21.000000000 +0530
@@ -1207,6 +1207,8 @@ unlink08 unlink08
 #unlinkat test cases
 unlinkat01 unlinkat01
 
+unshare01 unshare01
+
 #
 # These tests require an unmounted block device
 # to run correctly. Please see individual test

---
Regards--
Manas


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [LTP] [PATCH 13/13] Add/Port unshare02 test for unshare() syscall
  2009-05-27 10:06 [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Manas Kumar Nayak
                   ` (11 preceding siblings ...)
  2009-05-27 10:12 ` [LTP] [PATCH 12/13] Add/Port unshare01 test for unshare() syscall Manas Kumar Nayak
@ 2009-05-27 10:13 ` Manas Kumar Nayak
  2009-05-29 12:57   ` Subrata Modak
  2009-05-29 12:55 ` [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Subrata Modak
  13 siblings, 1 reply; 31+ messages in thread
From: Manas Kumar Nayak @ 2009-05-27 10:13 UTC (permalink / raw)
  To: LTP List; +Cc: Manas Kumar Nayak

Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>
To: LTP List <ltp-list@lists.sourceforge.net>
Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
Cc: Masatake YAMATO <yamato@redhat.com>
---

--- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/unshare/unshare02.c	1970-01-01 05:30:00.000000000 +0530
+++ ltp-intermediate-20090521/testcases/kernel/syscalls/unshare/unshare02.c	2009-05-27 14:51:53.000000000 +0530
@@ -0,0 +1,183 @@
+/******************************************************************************/
+/* Copyright (c) Crackerjack Project., 2007                                   */
+/*                                                                            */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
+/*                                                                            */
+/******************************************************************************/
+/******************************************************************************/
+/*                                                                            */
+/* File:        unshare02.c                                                   */
+/*                                                                            */
+/* Description: This tests the unshare error() syscall                        */
+/*                                                                            */
+/* Usage:  <for command-line>                                                 */
+/* unshare02 [-c n] [-e][-i n] [-I x] [-p x] [-t]                             */
+/*      where,  -c n : Run n copies concurrently.                             */
+/*              -e   : Turn on errno logging.                                 */
+/*              -i n : Execute test n times.                                  */
+/*              -I x : Execute test for x seconds.                            */
+/*              -P x : Pause for x seconds between iterations.                */
+/*              -t   : Turn on syscall timing.                                */
+/*                                                                            */
+/* Total Tests: 2                                                             */
+/*                                                                            */
+/* Test Name:   unshare02                                                     */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
+/******************************************************************************/
+
+#include <stdio.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <sched.h>
+#include <limits.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <errno.h>
+#include <pwd.h>
+#include <grp.h>
+#include <string.h>
+#include <sys/param.h>
+#include <stdio.h>
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+#include "linux_syscall_numbers.h"
+
+/* Extern Global Variables */
+extern int Tst_count;           /* counter for tst_xxx routines.         */
+extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "unshare02";  /* Test program identifier.*/
+int  testno;
+int  TST_TOTAL = 2;                   /* total number of tests in this file.   */
+
+/* Extern Global Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    cleanup                                                       */
+/*                                                                            */
+/* Description: Performs all one time clean up for this test on successful    */
+/*              completion,  premature exit or  failure. Closes all temporary */
+/*              files, removes all temporary directories exits the test with  */
+/*              appropriate TEST_RETURNurn code by calling tst_exit() function.       */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits calling tst_exit(). Non '0' TEST_RETURNurn code.   */
+/*              On success - Exits calling tst_exit(). With '0' TEST_RETURNurn code.  */
+/*                                                                            */
+/******************************************************************************/
+extern void cleanup() {
+        /* Remove tmp dir and all files in it */
+        TEST_CLEANUP;
+        tst_rmdir();
+
+        /* Exit with appropriate TEST_RETURNurn code. */
+        tst_exit();
+}
+
+/* Local  Functions */
+/******************************************************************************/
+/*                                                                            */
+/* Function:    setup                                                         */
+/*                                                                            */
+/* Description: Performs all one time setup for this test. This function is   */
+/*              typically used to capture signals, create temporary dirs      */
+/*              and temporary files that may be used in the course of this    */
+/*              test.                                                         */
+/*                                                                            */
+/* Input:       None.                                                         */
+/*                                                                            */
+/* Output:      None.                                                         */
+/*                                                                            */
+/* Return:      On failure - Exits by calling cleanup().                      */
+/*              On success - TEST_RETURNurns 0.                                       */
+/*                                                                            */
+/******************************************************************************/
+void setup() {
+        /* Capture signals if any */
+        /* Create temporary directories */
+        TEST_PAUSE;
+        tst_tmpdir();
+}
+
+int main(int ac, char **av) {
+        pid_t pid1;
+	int lc;                 /* loop counter */
+        char *msg;              /* message TEST_RETURNurned from parse_opts */
+	
+        /* parse standard options */
+        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
+             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+             tst_exit();
+           }
+
+        setup();
+
+        /* Check looping state if -i option given */
+        for (lc = 0; TEST_LOOPING(lc); ++lc) {
+                Tst_count = 0;
+                for (testno = 0; testno < TST_TOTAL; ++testno) {
+
+ /*
+ *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));
+			cleanup();
+			tst_exit();
+			}
+			else if (TEST_RETURN == 0){
+				if((TEST_RETURN = unshare(-1)) == 0) {
+	        		tst_resm(TPASS, "Call succeeded");
+				tst_exit();
+				}
+				else if (TEST_RETURN == -1 ){
+					tst_resm(TFAIL,"Test Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+					tst_exit();
+                     			}
+			}
+
+			TEST(pid1=fork());    //call to fork()
+                        if (pid1 == -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((int)NULL)) == 0) {
+                                tst_resm(TPASS, "Call succeeded");
+				tst_exit();
+                                }
+                                else if (TEST_RETURN == -1 ){
+                                        tst_resm(TFAIL,"Test Failed 2, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
+					tst_exit();
+                                        }
+                        }
+
+
+                }
+	}
+	cleanup();
+        tst_exit();
+}
+
--- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 14:49:30.000000000 +0530
+++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 14:57:51.000000000 +0530
@@ -1208,6 +1208,7 @@ unlink08 unlink08
 unlinkat01 unlinkat01
 
 unshare01 unshare01
+unshare02 unshare02
 
 #
 # These tests require an unmounted block device

---
Regards--
Manas


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP
  2009-05-27 10:06 [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Manas Kumar Nayak
                   ` (12 preceding siblings ...)
  2009-05-27 10:13 ` [LTP] [PATCH 13/13] Add/Port unshare02 " Manas Kumar Nayak
@ 2009-05-29 12:55 ` Subrata Modak
  13 siblings, 0 replies; 31+ messages in thread
From: Subrata Modak @ 2009-05-29 12:55 UTC (permalink / raw)
  To: Manas Kumar Nayak; +Cc: LTP List

On Wed, 2009-05-27 at 15:36 +0530, Manas Kumar Nayak wrote: 
> Hi,
> 
> >On Tue, 2009-05-19 at 00:39 +0530, Manas Kumar Nayak wrote:
> >Hi,
> > 
> > I have ported the following tests from Crackerjack to LTP.
> > Kindly include them to LTP:
> > 
> > [PATCH 01/21] Add add_key01 test for add_key syscall
> > [PATCH 02/21] Add add_key02 test for add_key syscall
> > [PATCH 03/21] Add bdflush01 test for bdflush syscall
> > [PATCH 04/21] Add exit_group01 test for exit_group syscall
> > [PATCH 05/21] Add keyctl01 test for keyctl syscall
> > [PATCH 06/21] Add newuname01 test for newuname syscall
> > [PATCH 07/21] Add rt_sigaction01 test for rt_sigaction syscall
> > [PATCH 08/21] Add rt_sigprocmask01 test for rt_sigprocmask syscall
> > [PATCH 09/21] Add rt_sigprocmask02 test for rt_sigprocmask syscall
> > [PATCH 10/21] Add rt_sigqueueinfo01 test for rt_sigqueueinfo syscall
> > [PATCH 11/21] Add rt_sigsuspend01 test for rt_sigsuspend syscall
> > [PATCH 12/21] Add set_thread_area01 test for set_thread_area syscall
> > [PATCH 13/21] Add set_thread_area02 test for set_thread_area syscall
> > [PATCH 14/21] Add set_tid_address01 test for set_tid_address syscall
> > [PATCH 15/21] Add sgetmask01 test for sgetmask syscall
> > [PATCH 16/21] Add sigreturn01 test for sigreturn syscall
> > [PATCH 17/21] Add ssetmask01 test for ssetmask syscall
> > [PATCH 18/21] Add timer_getoverrun01 test for timer_getoverrun01 syscall
> > [PATCH 19/21] Add timer_gettime01 test for timer_gettime syscall
> > [PATCH 20/21] Add tkill01 test for tkill syscall
> > [PATCH 21/21] Add tkill02 test for tkill syscall
> > 
> > Todo:
> > 	1) Port the Remaining ones (next week),
> 
> As promised earlier, here remains the 2nd Bunch of tests ported
> from Crackerjack to LTP:
> 
> __001_Add_Utility_Headers_for_these_set_of_tests.patch
> __002_Add_get_mempolicy01_test_for_get_mempolicy_syscall.patch
> __003_Add_clock_getres01_test_for_clock_getres_syscall.patch
> __004_Add_clock_nanosleep01_test_for_clock_nanosleep_syscall.patch
> __005_Add_mq_notify01_test_for_mq_notify_syscall.patch
> __006_Add_ppoll01_test_for_ppoll_syscall.patch
> __007_Add_mq_open01_test_for_mq_open_syscall.patch
> __008_Add_mq_timedreceive01_test_for_mq_timedreceive_syscall.patch
> __009_Add_utimes01_test_for_utimes_syscall.patch
> __010_Add_mq_unlink01_test_for_mq_unlink_syscall.patch
> __011_Add_mq_timedsend01_test_for_mq_timedsend_syscall.patch
> __012_Add_unshare01_test_for_unshare_syscall.patch
> __013_Add_unshare02_test_for_unshare_syscall.patch

Thanks a ton.

> 
> Still TODO:
> -> The remaining testcases will be ported soon.

Great to know that as well.

Regards--
Subrata

> 
> Regards--
> Manas
> 
> > 
> > Regards--
> > Manas
> > 


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [LTP] [PATCH 01/13] Add/Port Utility Headers for these set of tests
  2009-05-27 10:07 ` [LTP] [PATCH 01/13] Add/Port Utility Headers for these set of tests Manas Kumar Nayak
@ 2009-05-29 12:55   ` Subrata Modak
  0 siblings, 0 replies; 31+ messages in thread
From: Subrata Modak @ 2009-05-29 12:55 UTC (permalink / raw)
  To: Manas Kumar Nayak; +Cc: LTP List

On Wed, 2009-05-27 at 15:37 +0530, Manas Kumar Nayak wrote: 
> Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>

Thanks. Merged.

Regards--
Subrata

> To: LTP List <ltp-list@lists.sourceforge.net>
> Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
> Cc: Masatake YAMATO <yamato@redhat.com>
> ---
> 
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/utils/common_j_h.c	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/utils/common_j_h.c	2009-05-18 21:35:36.000000000 +0530
> @@ -0,0 +1,360 @@
> +/*
> + * Crackerjack Project
> + *
> + * Copyright (C) 2007-2008, Hitachi, Ltd.
> + * Author(s): Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
> + *            Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> + *
> + * $Id:$
> + *
> + */
> +//#define _GNU_SOURCE 1
> +#include <stdio.h>
> +#include <sys/types.h>
> +#include <sys/wait.h>
> +#include <sys/stat.h>
> +#include <sys/time.h>
> +#include <sys/resource.h>
> +#include <fcntl.h>
> +#include <unistd.h>
> +#include <pwd.h>
> +#include <signal.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <errno.h>
> +#include <mqueue.h>
> +#include "include_j_h.h"
> +
> +
> +/*
> + * Change user ID
> + *
> + *   We assume 'test' executable is executed with 'root' permission.
> + *   So, if you use this function, you can not return 'root' uid.
> + */
> +int setup_uid(char *uname)
> +{
> +	struct passwd *pw;
> +	int rc;
> +
> +	pw = getpwnam(uname);
> +	if (!pw) {
> +		EPRINTF("getpwnam failed.\n");
> +		return -1;
> +	}
> +	rc = setuid(pw->pw_uid);
> +	if (rc < 0) {
> +		EPRINTF("setuid failed.\n");
> +		return -1;
> +	}
> +	return 0;
> +}
> +
> +/*
> + * Change effective user ID
> + */
> +int setup_euid(char *uname, uid_t *old_uid)
> +{
> +	struct passwd *pw;
> +	int rc;
> +
> +	*old_uid = geteuid();
> +	pw = getpwnam(uname);
> +	if (!pw) {
> +		EPRINTF("getpwnam failed.\n");
> +		return -1;
> +	}
> +	rc = seteuid(pw->pw_uid);
> +	if (rc < 0) {
> +		EPRINTF("seteuid failed.\n");
> +		return -1;
> +	}
> +	return 0;
> +}
> +
> +int cleanup_euid(uid_t old_uid)
> +{
> +	int rc;
> +
> +	rc = seteuid(old_uid);
> +	if (rc < 0) {
> +		EPRINTF("seteuid failed.\n");
> +		return -1;
> +	}
> +	return 0;
> +}
> +
> +
> +/*
> + * Generate a child process which will send a signal
> + */
> +static void sighandler_for_sig_proc(int sig)
> +{
> +	if (sig == SIGUSR2)
> +		return;
> +	return;
> +}
> +
> +pid_t create_sig_proc(unsigned long usec, int sig)
> +{
> +	pid_t pid, cpid;
> +
> +	signal(SIGUSR2, sighandler_for_sig_proc);
> +	pid = getpid();
> +	cpid = fork();
> +	switch (cpid) {
> +	case 0:
> +		pause();
> +		usleep(usec);
> +		kill(pid, sig);
> +		_exit(0);
> +		break;
> +	case -1:
> +		EPRINTF("fork failed.\n");
> +		return cpid;
> +	default:
> +		kill(cpid, SIGUSR2);
> +		return cpid;
> +	}
> +}
> +
> +
> +/*
> + * Create and delete test file
> + */
> +int setup_file(char *testdir, char *fname, char *path)
> +{
> +	return _setup_file(testdir, fname, path,
> +			   O_CREAT|O_EXCL|O_RDWR, S_IRUSR|S_IWUSR);
> +}
> +
> +int _setup_file(char *testdir, char *fname, char *path, int flags, mode_t mode)
> +{
> +	int rc;
> +
> +	sprintf(path, "%s/%s", testdir, fname);
> +	rc = open(path, flags, mode);
> +	if (rc < 0) {
> +		EPRINTF("open failed.\n");
> +		return -1;
> +	}
> +	return rc;
> +}
> +
> +int cleanup_file(char *path)
> +{
> +	unlink(path);
> +	return 0;
> +}
> +
> +
> +/*
> + * Create and delete swap file
> + */
> +/* swap file needs to be more than 40KB */
> +#define MIN_SWAPFILE_SIZE	(64 * 1024)
> +int setup_swapfile(char *testdir, char *fname, char *path, size_t size)
> +{
> +	int fd = -1, rc;
> +	size_t r_sz;
> +	int cmdlen = 256;
> +	char cmd[cmdlen];
> +	char *p = NULL;
> +
> +	sprintf(path, "%s/%s", testdir, fname);
> +	fd = open(path, O_CREAT|O_EXCL|O_RDWR, S_IRUSR|S_IWUSR);
> +	if (fd < 0) {
> +		EPRINTF("open failed.\n");
> +		goto ERR_EXIT;
> +	}
> +	if (size < MIN_SWAPFILE_SIZE) {
> +		EPRINTF("size too short.\n");
> +		goto ERR_EXIT;
> +	}
> +	p = malloc(size);
> +	if (!p) {
> +		EPRINTF("malloc failed.\n");
> +		goto ERR_EXIT;
> +	}
> +	/* Swap file must not have hole area */
> +	memset(p, 0x5a, size);
> +	r_sz = (size_t)write(fd, p, size);
> +	if (r_sz != size) {
> +		EPRINTF("write failed.\n");
> +		goto ERR_EXIT;
> +	}
> +	snprintf(cmd, cmdlen, "/sbin/mkswap %s > /dev/null 2>&1", path);
> +	rc = system(cmd);
> +	if (rc != 0) {
> +		EPRINTF("system(%s) failed.\n", cmd);
> +		goto ERR_EXIT;
> +	}
> +	return fd;
> +
> +ERR_EXIT:
> +	if (fd >= 0)
> +		close(fd);
> +	if (p)
> +		free(p);
> +	return -1;
> +}
> +
> +int cleanup_swapfile(char *path)
> +{
> +	unlink(path);
> +	return 0;
> +}
> +
> +
> +/*
> + * Change user limit that the calling process can open
> + */
> +int setup_ulimit_fnum(rlim_t newlim, rlim_t *oldlim)
> +{
> +	int rc;
> +	struct rlimit rlim;
> +
> +	rc = getrlimit(RLIMIT_NOFILE, &rlim);
> +	if (rc < 0) {
> +		EPRINTF("getrlimit failed.\n");
> +		return -1;
> +	}
> +	*oldlim = rlim.rlim_cur;
> +	if (newlim > rlim.rlim_max) {
> +		EPRINTF("can't set ulimit value: %ld.\n", newlim);
> +		return -1;
> +	}
> +	rlim.rlim_cur = newlim;
> +	rc = setrlimit(RLIMIT_NOFILE, &rlim);
> +	if (rc < 0) {
> +		EPRINTF("setrlimit failed.\n");
> +		return -1;
> +	}
> +	return 0;
> +}
> +
> +int cleanup_ulimit_fnum(rlim_t oldlim)
> +{
> +	int rc;
> +	struct rlimit rlim;
> +
> +	rc = getrlimit(RLIMIT_NOFILE, &rlim);
> +	if (rc < 0) {
> +		EPRINTF("getrlimit failed.\n");
> +		return -1;
> +	}
> +	if (oldlim > rlim.rlim_max) {
> +		EPRINTF("can't set ulimit value: %ld.\n", oldlim);
> +		return -1;
> +	}
> +	rlim.rlim_cur = oldlim;
> +	rc = setrlimit(RLIMIT_NOFILE, &rlim);
> +	if (rc < 0) {
> +		EPRINTF("setrlimit failed.\n");
> +		return -1;
> +	}
> +	return 0;
> +}
> +
> +
> +/*
> + * Change /proc or /sys setting
> + */
> +int setup_proc_fs(char *path, int newval, int *oldval)
> +{
> +	int fd = -1, rc, len;
> +	char buf[32];
> +
> +	fd = open(path, O_RDWR);
> +	if (fd < 0) {
> +		EPRINTF("open %s failed.\n", path);
> +		return -1;
> +	}
> +
> +	do {
> +		rc = read(fd, buf, 32);
> +	} while (rc < 0 && errno == EAGAIN);
> +	if (rc < 0) {
> +		EPRINTF("read failed.\n");
> +		return -1;
> +	}
> +
> +	*oldval = atoi(buf);
> +	sprintf(buf, "%d\n", newval);
> +	len = strlen(buf);
> +	rc = write(fd, buf, len);
> +	if (rc != len) {
> +		EPRINTF("write failed.\n");
> +		return -1;
> +	}
> +	return 0;
> +}
> +
> +int cleanup_proc_fs(char *path, int oldval)
> +{
> +	int fd = -1, rc, len;
> +	char buf[32];
> +
> +	fd = open(path, O_RDWR);
> +	if (fd < 0) {
> +		EPRINTF("open %s failed.\n", path);
> +		return -1;
> +	}
> +
> +	sprintf(buf, "%d\n", oldval);
> +	len = strlen(buf);
> +	rc = write(fd, buf, len);
> +	if (rc != len) {
> +		EPRINTF("write failed.\n");
> +		return -1;
> +	}
> +	return 0;
> +}
> +
> +
> +#if 0
> +/*
> + * Check max nodes from /sys/devices/system/node/node* files (for NUMA)
> + */
> +int get_max_nodes(void)
> +{
> +	/* We assume that there is only one node */
> +	return 1;
> +}
> +#endif
> +
> +/*
> + * Get unexist pid
> + */
> +pid_t get_unexist_pid(void)
> +{
> +	pid_t pid;
> +	int st;
> +
> +	pid = fork();
> +	switch (pid) {
> +	case -1:
> +		EPRINTF("fork failed.\n");
> +		return -1;
> +	case 0:
> +		_exit(0);
> +	default:
> +		wait(&st);
> +		return pid;
> +	}
> +}
> +
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/utils/include_j_h.h	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/utils/include_j_h.h	2009-05-18 21:35:36.000000000 +0530
> @@ -0,0 +1,160 @@
> +/*
> + * Crackerjack Project
> + *
> + * Copyright (C) 2007-2008, Hitachi, Ltd.
> + * Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,
> + *            Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
> + *            Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> + *
> + * $Id:$
> + *
> + */
> +#ifndef __CJK_SYSCALL_J_H__
> +#define __CJK_SYSCALL_J_H__
> +
> +#include <sys/time.h>
> +#include <sys/resource.h>
> +
> +
> +#define REG_RESULT_LOG_FP	stdout
> +#define REG_DETAIL_LOG_FP	stderr
> +
> +
> +/*
> + * RPRINTF : macro to output test result
> + */
> +#define RPRINTF(...)						\
> +	do {							\
> +		fprintf(REG_RESULT_LOG_FP, __VA_ARGS__);	\
> +	} while (0)
> +
> +
> +/*
> + * PRINTF : macro to output detail log
> + */
> +#define PRINTF(...)						\
> +	do {							\
> +		fprintf(REG_DETAIL_LOG_FP, __VA_ARGS__);	\
> +	} while (0)
> +
> +
> +/*
> + * EPRINTF : macro to output error message
> + */
> +#define EPRINTF(...)						\
> +	do {							\
> +		fprintf(REG_DETAIL_LOG_FP, __VA_ARGS__);	\
> +	} while (0)
> +
> +
> +/*
> + * DPRINTF : macro to output debug message
> + */
> +#define DPRINTF(...)						\
> +	do {							\
> +		if (opt_debug)					\
> +			PRINTF("[DEBUG] " __VA_ARGS__);		\
> +	} while (0)
> +
> +
> +/*
> + * PRINT_XXX : macro to output test result and expect
> + */
> +#define __PRINT_EXPECT(rc_has_range, rc, errno)				\
> +	do {								\
> +		if (rc_has_range)					\
> +			PRINTF("EXPECT: return value(ret)=%s",		\
> +			       (rc) >= 0 ? "(N >= 0)" : "(N <  0)");	\
> +		else							\
> +			PRINTF("EXPECT: return value(ret)=%d", rc);	\
> +		PRINTF(" errno=%d (%s)", errno, strerror(errno));	\
> +	} while (0)
> +
> +#define __PRINT_RESULT(rc_has_range, rc, errno)				\
> +	do {								\
> +		if (rc_has_range)					\
> +			PRINTF("RESULT: return value(ret)=%8d", rc);	\
> +		else							\
> +			PRINTF("RESULT: return value(ret)=%d", rc);	\
> +		PRINTF(" errno=%d (%s)", errno, strerror(errno));	\
> +	} while (0)
> +
> +#define PRINT_RESULT(rc_has_range, e_rc, e_errno, r_rc, r_errno)	\
> +	do {								\
> +		__PRINT_EXPECT(rc_has_range, e_rc, e_errno);		\
> +		PRINTF("\n");						\
> +		__PRINT_RESULT(rc_has_range, r_rc, r_errno);		\
> +		PRINTF("\n");						\
> +	} while (0)
> +
> +#define PRINT_RESULT_EXTRA(rc_has_range, e_rc, e_errno, r_rc, r_errno,	\
> +			   str, extra_ok)				\
> +	do {								\
> +		__PRINT_EXPECT(rc_has_range, e_rc, e_errno);		\
> +		if ((extra_ok))						\
> +			PRINTF("\n");					\
> +		else							\
> +			PRINTF(", %s=OK\n", str);			\
> +		__PRINT_RESULT(rc_has_range, r_rc, r_errno);		\
> +		if ((extra_ok))						\
> +			PRINTF("\n");					\
> +		else							\
> +			PRINTF(", %s=NG\n", str);			\
> +	} while (0)
> +
> +#define PRINT_RESULT_CMP(rc_has_range, e_rc, e_errno, r_rc, r_errno, cmp_ok) \
> +	PRINT_RESULT_EXTRA(rc_has_range, e_rc, e_errno, r_rc, r_errno,	\
> +			   "r/w check", cmp_ok)
> +
> +
> +/*
> + * Definitions
> + */
> +enum result_val {
> +	RESULT_OK,
> +	RESULT_NG
> +};
> +
> +
> +/*
> + * Prototype
> + */
> +int setup_uid(char *uname);
> +int setup_euid(char *uname, uid_t *old_uid);
> +int cleanup_euid(uid_t old_uid);
> +
> +pid_t create_sig_proc(unsigned long usec, int sig);
> +
> +int _setup_file(char *testdir, char *fname, char *path, int flags, mode_t mode);
> +int setup_file(char *testdir, char *fname, char *path);
> +int cleanup_file(char *path);
> +
> +int setup_swapfile(char *testdir, char *fname, char *path, size_t size);
> +int cleanup_swapfile(char *path);
> +
> +int setup_ulimit_fnum(rlim_t newlim, rlim_t *oldlim);
> +int cleanup_ulimit_fnum(rlim_t oldlim);
> +
> +int setup_proc_fs(char *path, int newval, int *oldval);
> +int cleanup_proc_fs(char *path, int oldval);
> +
> +#define QUEUE_NAME	"/test_mqueue"
> +pid_t create_echo_msg_proc(void);
> +
> +pid_t get_unexist_pid(void);
> +
> +#endif /* __CJK_SYSCALL_J_H__ */
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/utils/inotify.h	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/utils/inotify.h	2009-05-18 21:35:36.000000000 +0530
> @@ -0,0 +1,227 @@
> +/*
> + * Inode based directory notification for Linux
> + *
> + * Copyright (C) 2005 John McCutchan
> + */
> +
> +#ifndef _LINUX_INOTIFY_H
> +#define _LINUX_INOTIFY_H
> +
> +#include <linux/types.h>
> +
> +/*
> + * struct inotify_event - structure read from the inotify device for each event
> + *
> + * When you are watching a directory, you will receive the filename for events
> + * such as IN_CREATE, IN_DELETE, IN_OPEN, IN_CLOSE, ..., relative to the wd.
> + */
> +struct inotify_event {
> +	__s32		wd;		/* watch descriptor */
> +	__u32		mask;		/* watch mask */
> +	__u32		cookie;		/* cookie to synchronize two events */
> +	__u32		len;		/* length (including nulls) of name */
> +	char		name[0];	/* stub for possible name */
> +};
> +
> +/* the following are legal, implemented events that user-space can watch for */
> +#define IN_ACCESS		0x00000001	/* File was accessed */
> +#define IN_MODIFY		0x00000002	/* File was modified */
> +#define IN_ATTRIB		0x00000004	/* Metadata changed */
> +#define IN_CLOSE_WRITE		0x00000008	/* Writtable file was closed */
> +#define IN_CLOSE_NOWRITE	0x00000010	/* Unwrittable file closed */
> +#define IN_OPEN			0x00000020	/* File was opened */
> +#define IN_MOVED_FROM		0x00000040	/* File was moved from X */
> +#define IN_MOVED_TO		0x00000080	/* File was moved to Y */
> +#define IN_CREATE		0x00000100	/* Subfile was created */
> +#define IN_DELETE		0x00000200	/* Subfile was deleted */
> +#define IN_DELETE_SELF		0x00000400	/* Self was deleted */
> +#define IN_MOVE_SELF		0x00000800	/* Self was moved */
> +
> +/* the following are legal events.  they are sent as needed to any watch */
> +#define IN_UNMOUNT		0x00002000	/* Backing fs was unmounted */
> +#define IN_Q_OVERFLOW		0x00004000	/* Event queued overflowed */
> +#define IN_IGNORED		0x00008000	/* File was ignored */
> +
> +/* helper events */
> +#define IN_CLOSE		(IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* close */
> +#define IN_MOVE			(IN_MOVED_FROM | IN_MOVED_TO) /* moves */
> +
> +/* special flags */
> +#define IN_ONLYDIR		0x01000000	/* only watch the path if it is a directory */
> +#define IN_DONT_FOLLOW		0x02000000	/* don't follow a sym link */
> +#define IN_MASK_ADD		0x20000000	/* add to the mask of an already existing watch */
> +#define IN_ISDIR		0x40000000	/* event occurred against dir */
> +#define IN_ONESHOT		0x80000000	/* only send event once */
> +
> +/*
> + * All of the events - we build the list by hand so that we can add flags in
> + * the future and not break backward compatibility.  Apps will get only the
> + * events that they originally wanted.  Be sure to add new events here!
> + */
> +#define IN_ALL_EVENTS	(IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \
> +			 IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \
> +			 IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \
> +			 IN_MOVE_SELF)
> +
> +#ifdef __KERNEL__
> +
> +#include <linux/dcache.h>
> +#include <linux/fs.h>
> +
> +/*
> + * struct inotify_watch - represents a watch request on a specific inode
> + *
> + * h_list is protected by ih->mutex of the associated inotify_handle.
> + * i_list, mask are protected by inode->inotify_mutex of the associated inode.
> + * ih, inode, and wd are never written to once the watch is created.
> + *
> + * Callers must use the established inotify interfaces to access inotify_watch
> + * contents.  The content of this structure is private to the inotify
> + * implementation.
> + */
> +struct inotify_watch {
> +	struct list_head	h_list;	/* entry in inotify_handle's list */
> +	struct list_head	i_list;	/* entry in inode's list */
> +	atomic_t		count;	/* reference count */
> +	struct inotify_handle	*ih;	/* associated inotify handle */
> +	struct inode		*inode;	/* associated inode */
> +	__s32			wd;	/* watch descriptor */
> +	__u32			mask;	/* event mask for this watch */
> +};
> +
> +struct inotify_operations {
> +	void (*handle_event)(struct inotify_watch *, u32, u32, u32,
> +			     const char *, struct inode *);
> +	void (*destroy_watch)(struct inotify_watch *);
> +};
> +
> +#ifdef CONFIG_INOTIFY
> +
> +/* Kernel API for producing events */
> +
> +extern void inotify_d_instantiate(struct dentry *, struct inode *);
> +extern void inotify_d_move(struct dentry *);
> +extern void inotify_inode_queue_event(struct inode *, __u32, __u32,
> +				      const char *, struct inode *);
> +extern void inotify_dentry_parent_queue_event(struct dentry *, __u32, __u32,
> +					      const char *);
> +extern void inotify_unmount_inodes(struct list_head *);
> +extern void inotify_inode_is_dead(struct inode *);
> +extern u32 inotify_get_cookie(void);
> +
> +/* Kernel Consumer API */
> +
> +extern struct inotify_handle *inotify_init(const struct inotify_operations *);
> +extern void inotify_init_watch(struct inotify_watch *);
> +extern void inotify_destroy(struct inotify_handle *);
> +extern __s32 inotify_find_watch(struct inotify_handle *, struct inode *,
> +				struct inotify_watch **);
> +extern __s32 inotify_find_update_watch(struct inotify_handle *, struct inode *,
> +				       u32);
> +extern __s32 inotify_add_watch(struct inotify_handle *, struct inotify_watch *,
> +			       struct inode *, __u32);
> +extern int inotify_rm_watch(struct inotify_handle *, struct inotify_watch *);
> +extern int inotify_rm_wd(struct inotify_handle *, __u32);
> +extern void inotify_remove_watch_locked(struct inotify_handle *,
> +					struct inotify_watch *);
> +extern void get_inotify_watch(struct inotify_watch *);
> +extern void put_inotify_watch(struct inotify_watch *);
> +
> +#else
> +
> +static inline void inotify_d_instantiate(struct dentry *dentry,
> +					struct inode *inode)
> +{
> +}
> +
> +static inline void inotify_d_move(struct dentry *dentry)
> +{
> +}
> +
> +static inline void inotify_inode_queue_event(struct inode *inode,
> +					     __u32 mask, __u32 cookie,
> +					     const char *filename,
> +					     struct inode *n_inode)
> +{
> +}
> +
> +static inline void inotify_dentry_parent_queue_event(struct dentry *dentry,
> +						     __u32 mask, __u32 cookie,
> +						     const char *filename)
> +{
> +}
> +
> +static inline void inotify_unmount_inodes(struct list_head *list)
> +{
> +}
> +
> +static inline void inotify_inode_is_dead(struct inode *inode)
> +{
> +}
> +
> +static inline u32 inotify_get_cookie(void)
> +{
> +	return 0;
> +}
> +
> +static inline struct inotify_handle *inotify_init(const struct inotify_operations *ops)
> +{
> +	return ERR_PTR(-EOPNOTSUPP);
> +}
> +
> +static inline void inotify_init_watch(struct inotify_watch *watch)
> +{
> +}
> +
> +static inline void inotify_destroy(struct inotify_handle *ih)
> +{
> +}
> +
> +static inline __s32 inotify_find_watch(struct inotify_handle *ih, struct inode *inode,
> +				       struct inotify_watch **watchp)
> +{
> +	return -EOPNOTSUPP;
> +}
> +
> +static inline __s32 inotify_find_update_watch(struct inotify_handle *ih,
> +					      struct inode *inode, u32 mask)
> +{
> +	return -EOPNOTSUPP;
> +}
> +
> +static inline __s32 inotify_add_watch(struct inotify_handle *ih,
> +				      struct inotify_watch *watch,
> +				      struct inode *inode, __u32 mask)
> +{
> +	return -EOPNOTSUPP;
> +}
> +
> +static inline int inotify_rm_watch(struct inotify_handle *ih,
> +				   struct inotify_watch *watch)
> +{
> +	return -EOPNOTSUPP;
> +}
> +
> +static inline int inotify_rm_wd(struct inotify_handle *ih, __u32 wd)
> +{
> +	return -EOPNOTSUPP;
> +}
> +
> +static inline void inotify_remove_watch_locked(struct inotify_handle *ih,
> +					       struct inotify_watch *watch)
> +{
> +}
> +
> +static inline void get_inotify_watch(struct inotify_watch *watch)
> +{
> +}
> +
> +static inline void put_inotify_watch(struct inotify_watch *watch)
> +{
> +}
> +
> +#endif	/* CONFIG_INOTIFY */
> +
> +#endif	/* __KERNEL __ */
> +
> +#endif	/* _LINUX_INOTIFY_H */
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/utils/ioprio.h	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/utils/ioprio.h	2009-05-18 21:35:36.000000000 +0530
> @@ -0,0 +1,46 @@
> +#ifndef __IOPRIO_H__
> +#define	__IOPRIO_H__
> +
> +//----------------------------------------------------------------------------
> +// Copy of the 2.6.18 kernel header (linux/ioprio.h)
> +//
> +
> +/*
> + * Gives us 8 prio classes with 13-bits of data for each class
> + */
> +#define IOPRIO_BITS		(16)
> +#define IOPRIO_CLASS_SHIFT	(13)
> +#define IOPRIO_PRIO_MASK	((1UL << IOPRIO_CLASS_SHIFT) - 1)
> +
> +#define IOPRIO_PRIO_CLASS(mask)	((mask) >> IOPRIO_CLASS_SHIFT)
> +#define IOPRIO_PRIO_DATA(mask)	((mask) & IOPRIO_PRIO_MASK)
> +#define IOPRIO_PRIO_VALUE(class, data)	(((class) << IOPRIO_CLASS_SHIFT) | data)
> +
> +#define ioprio_valid(mask)	(IOPRIO_PRIO_CLASS((mask)) != IOPRIO_CLASS_NONE)
> +
> +/*
> + * These are the io priority groups as implemented by CFQ. RT is the realtime
> + * class, it always gets premium service. BE is the best-effort scheduling
> + * class, the default for any process. IDLE is the idle scheduling class, it
> + * is only served when no one else is using the disk.
> + */
> +enum {
> +	IOPRIO_CLASS_NONE,
> +	IOPRIO_CLASS_RT,
> +	IOPRIO_CLASS_BE,
> +	IOPRIO_CLASS_IDLE,
> +};
> +
> +/*
> + * 8 best effort priority levels are supported
> + */
> +#define IOPRIO_BE_NR	(8)
> +
> +enum {
> +	IOPRIO_WHO_PROCESS = 1,
> +	IOPRIO_WHO_PGRP,
> +	IOPRIO_WHO_USER,
> +};
> +//-----------------------------------------------------------------------------
> +
> +#endif /* __IOPRIO_H__ */
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/utils/numaif.h	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/utils/numaif.h	2009-05-18 21:35:36.000000000 +0530
> @@ -0,0 +1,115 @@
> +/*
> + * Crackerjack Project
> + *
> + * Copyright (C) 2007-2008, Hitachi, Ltd.
> + * Author(s): Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
> + *            Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>
> + *
> + *            Derived from 'numa.h' in numactl-0.9.8
> + *            Copyright (C) 2003,2004 Andi Kleen, SuSE Labs.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> + *
> + * $Id:$
> + *
> + */
> +
> +#include "./include_j_h.h"
> +
> +#ifndef __NR_mbind
> +#  define __NR_mbind			274
> +#endif
> +#ifndef __NR_get_mempolicy
> +#  define __NR_get_mempolicy		275
> +#endif
> +#ifndef __NR_set_mempolicy
> +#  define __NR_set_mempolicy		276
> +#endif
> +#ifndef __NR_migrate_pages
> +#  define __NR_migrate_pages		294
> +#endif
> +#ifndef __NR_move_pages
> +#  define __NR_move_pages		317
> +#endif
> +
> +
> +
> +
> +#define NUMA_NUM_NODES 	128
> +typedef struct { 
> +	unsigned long n[NUMA_NUM_NODES/(sizeof(unsigned long)*8)];
> +} nodemask_t;
> +
> +static inline void nodemask_zero(nodemask_t *mask)
> +{ 
> +	memset(mask->n, 0, sizeof(mask->n)); 
> +} 
> +
> +static inline void nodemask_set(nodemask_t *mask, int node)
> +{
> +	mask->n[node / (8*sizeof(unsigned long))] |=
> +		(1UL << (node % (8*sizeof(unsigned long))));		
> +} 
> +
> +static inline void nodemask_clr(nodemask_t *mask, int node)
> +{
> +	mask->n[node / (8*sizeof(unsigned long))] &= 
> +		~(1UL << (node % (8*sizeof(unsigned long))));	
> +}
> +
> +static inline int nodemask_isset(const nodemask_t *mask, int node)
> +{
> +	if ((unsigned)node >= NUMA_NUM_NODES)
> +		return 0;
> +	if (mask->n[node / (8*sizeof(unsigned long))] & 
> +		(1UL << (node % (8*sizeof(unsigned long)))))
> +		return 1;
> +	return 0;	
> +}
> +
> +static inline int nodemask_equal(const nodemask_t *a, const nodemask_t *b) 
> +{ 
> +	int i;
> +	for (i = 0; i < NUMA_NUM_NODES/(sizeof(unsigned long)*8); i++) 
> +		if (a->n[i] != b->n[i]) 
> +			return 0; 
> +	return 1;
> +} 
> +
> +static inline void nodemask_dump(const char *header, const nodemask_t *mask)
> +{
> +	int i;
> +	EPRINTF("%s", header);
> +	for (i = 0; i < NUMA_NUM_NODES/(sizeof(unsigned long)*8); i++) 
> +		EPRINTF(" 0x%08lx", mask->n[i]);
> +	EPRINTF("\n");
> +}
> +
> +
> +#ifndef MPOL_DEFAULT
> +   // Policies
> +#  define MPOL_DEFAULT			0
> +#  define MPOL_PREFERRED		1
> +#  define MPOL_BIND			2
> +#  define MPOL_INTERLEAVE		3
> +   // Flags for get_mem_policy
> +#  define MPOL_F_NODE			(1<<0)
> +#  define MPOL_F_ADDR			(1<<1)
> +   // Flags for mbind
> +#  define MPOL_MF_STRICT		(1<<0)
> +#  define MPOL_MF_MOVE			(1<<1)
> +#  define MPOL_MF_MOVE_ALL		(1<<2)
> +#endif
> +
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/utils/poll.h	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/utils/poll.h	2009-05-18 21:35:36.000000000 +0530
> @@ -0,0 +1,27 @@
> +#ifndef __i386_POLL_H
> +#define __i386_POLL_H
> +
> +/* These are specified by iBCS2 */
> +#define POLLIN		0x0001
> +#define POLLPRI		0x0002
> +#define POLLOUT		0x0004
> +#define POLLERR		0x0008
> +#define POLLHUP		0x0010
> +#define POLLNVAL	0x0020
> +
> +/* The rest seem to be more-or-less nonstandard. Check them! */
> +#define POLLRDNORM	0x0040
> +#define POLLRDBAND	0x0080
> +#define POLLWRNORM	0x0100
> +#define POLLWRBAND	0x0200
> +#define POLLMSG		0x0400
> +#define POLLREMOVE	0x1000
> +#define POLLRDHUP       0x2000
> +
> +struct pollfd {
> +	int fd;
> +	short events;
> +	short revents;
> +};
> +
> +#endif
> 
> ---
> Regards--
> Manas
> 


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [LTP] [PATCH 02/13] Add/Port get_mempolicy01 test for get_mempolicy() syscall
  2009-05-27 10:07 ` [LTP] [PATCH 02/13] Add/Port get_mempolicy01 test for get_mempolicy() syscall Manas Kumar Nayak
@ 2009-05-29 12:55   ` Subrata Modak
  0 siblings, 0 replies; 31+ messages in thread
From: Subrata Modak @ 2009-05-29 12:55 UTC (permalink / raw)
  To: Manas Kumar Nayak; +Cc: LTP List

On Wed, 2009-05-27 at 15:37 +0530, Manas Kumar Nayak wrote: 
> Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>

Thanks.

Regards--
Subrata

> To: LTP List <ltp-list@lists.sourceforge.net>
> Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
> Cc: Masatake YAMATO <yamato@redhat.com>
> ---
> 
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c	2009-05-26 21:32:56.000000000 +0530
> @@ -0,0 +1,453 @@
> +/******************************************************************************/
> +/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
> +/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
> +/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
> +/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
> +/*                                                                  	      */
> +/* This program is free software;  you can redistribute it and/or modify      */
> +/* it under the terms of the GNU General Public License as published by       */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> +/*                                                                            */
> +/******************************************************************************/
> +/******************************************************************************/
> +/*                                                                            */
> +/* File:        get_mempolicy01.c                                             */
> +/*                                                                            */
> +/* Description: This tests the get_mempolicy() syscall                        */
> +/*									      */
> +/* 									      */
> +/*									      */
> +/*									      */
> +/*									      */
> +/*                                                                            */
> +/* Usage:  <for command-line>                                                 */
> +/* get_mempolicy01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                        */
> +/*      where,  -c n : Run n copies concurrently.                             */
> +/*              -e   : Turn on errno logging.                                 */
> +/*              -i n : Execute test n times.                                  */
> +/*              -I x : Execute test for x seconds.                            */
> +/*              -P x : Pause for x seconds between iterations.                */
> +/*              -t   : Turn on syscall timing.                                */
> +/*                                                                            */
> +/* Total Tests: 1                                                             */
> +/*                                                                            */
> +/* Test Name:   get_mempolicy01                                             */
> +/* History:     Porting from Crackerjack to LTP is done by                    */
> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
> +/******************************************************************************/
> +#include <sys/syscall.h>
> +#include <sys/types.h>
> +#include <sys/mman.h>
> +#include <getopt.h>
> +#include <string.h>
> +#include <stdlib.h>
> +#include <errno.h>
> +#include <stdio.h>
> +#include <unistd.h>
> +#include "../utils/numaif.h"
> +#include "../utils/include_j_h.h"
> +#include "../utils/common_j_h.c"
> +
> +/* Harness Specific Include Files. */
> +#include "test.h"
> +#include "usctest.h"
> +#include "linux_syscall_numbers.h"
> +
> +/* Extern Global Variables */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> +
> +/* Global Variables */
> +char *TCID = "get_mempolicy01";  /* Test program identifier.*/
> +int  testno;
> +int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
> +
> +/* Extern Global Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    cleanup                                                       */
> +/*                                                                            */
> +/* Description: Performs all one time clean up for this test on successful    */
> +/*              completion,  premature exit or  failure. Closes all temporary */
> +/*              files, removes all temporary directories exits the test with  */
> +/*              appropriate return code by calling tst_exit() function.       */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> +/*              On success - Exits calling tst_exit(). With '0' return code.  */
> +/*                                                                            */
> +/******************************************************************************/
> +extern void cleanup() {
> +        /* Remove tmp dir and all files in it */
> +        TEST_CLEANUP;
> +        tst_rmdir();
> +
> +        /* Exit with appropriate return code. */
> +        tst_exit();
> +}
> +
> +/* Local  Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    setup                                                         */
> +/*                                                                            */
> +/* Description: Performs all one time setup for this test. This function is   */
> +/*              typically used to capture signals, create temporary dirs      */
> +/*              and temporary files that may be used in the course of this    */
> +/*              test.                                                         */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits by calling cleanup().                      */
> +/*              On success - returns 0.                                       */
> +/*                                                                            */
> +/******************************************************************************/
> +void setup() {
> +        /* Capture signals if any */
> +        /* Create temporary directories */
> +        TEST_PAUSE;
> +        tst_tmpdir();
> +}
> +
> +
> +/*
> + * Macros
> + */
> +#define SYSCALL_NAME    "get_mempolicy"
> +
> +
> +/*
> + * Global variables
> + */
> +static int opt_debug;
> +static char *progname;
> +
> +enum test_type {
> +        DEFAULT,        // get default policy
> +        ADDR,           // get policy of memory which include mapped address
> +        INVALID_POINTER,
> +        INVALID_FLAGS,
> +};
> +
> +enum from_node {
> +        NONE,
> +        SELF,
> +};
> +
> +
> +/*
> + * Data Structure
> + */
> +struct test_case {
> +        int ttype;
> +        int policy;
> +        int from_node;
> +        int ret;
> +        int err;
> +};
> +
> +/* Test cases
> + *
> + *   test status of errors on man page
> + *
> + *   (NONE)             man page hadn't been completed.
> + *
> + *   test status of errors NOT on man page
> + *
> + *   EFAULT             v (invalid address)
> + *   EINVAL             v (invalid parameters)
> + */
> +
> +static struct test_case tcase[] = {
> +        { // case00
> +                .ttype          = DEFAULT,
> +                .policy         = MPOL_DEFAULT,
> +                .from_node      = NONE,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case01
> +                .ttype          = DEFAULT,
> +                .policy         = MPOL_BIND,
> +                .from_node      = SELF,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case02
> +                .ttype          = DEFAULT,
> +                .policy         = MPOL_INTERLEAVE,
> +                .from_node      = SELF,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +{ // case03
> +                .ttype          = DEFAULT,
> +                .policy         = MPOL_PREFERRED,
> +                .from_node      = NONE,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case04
> +                .ttype          = DEFAULT,
> +                .policy         = MPOL_PREFERRED,
> +                .from_node      = SELF,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case05
> +                .ttype          = ADDR,
> +                .policy         = MPOL_DEFAULT,
> +                .from_node      = NONE,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +{ // case06
> +                .ttype          = ADDR,
> +                .policy         = MPOL_BIND,
> +                .from_node      = SELF,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case07
> +                .ttype          = ADDR,
> +                .policy         = MPOL_INTERLEAVE,
> +                .from_node      = SELF,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case08
> +                .ttype          = ADDR,
> +                .policy         = MPOL_PREFERRED,
> +                .from_node      = NONE,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +{ // case09
> +                .ttype          = ADDR,
> +                .policy         = MPOL_PREFERRED,
> +                .from_node      = SELF,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case10
> +                .ttype          = INVALID_POINTER,
> +                .policy         = MPOL_DEFAULT,
> +                .from_node      = NONE,
> +                .ret            = -1,
> +                .err            = EFAULT,
> +        },
> +        { // case11
> +                .ttype          = INVALID_FLAGS,
> +                .policy         = MPOL_DEFAULT,
> +                .from_node      = NONE,
> +                .ret            = -1,
> +                .err            = EINVAL,
> +        },
> +};
> +
> +#define MEM_LENGTH              (4 * 1024 * 1024)
> +/*
> + * do_test()
> + *
> + *   Input  : TestCase Data
> + *   Return : RESULT_OK(0), RESULT_NG(1)
> + *
> + */
> +
> +static int do_test(struct test_case *tc)
> +{
> +        int sys_ret;
> +        int sys_errno;
> +        int result = RESULT_OK;
> +        int rc, policy, flags, cmp_ok = 1;
> +        nodemask_t nodemask, getnodemask;
> +        unsigned long maxnode = NUMA_NUM_NODES;
> +        char *p = NULL;
> +        unsigned long len = MEM_LENGTH;
> +
> +        /* We assume that there is only one node(node0). */
> +        nodemask_zero(&nodemask);
> +        nodemask_set(&nodemask, 0);
> +        nodemask_zero(&getnodemask);
> +
> +        switch (tc->ttype) {
> +        case DEFAULT:
> +                flags = 0;
> +                p = NULL;
> +                // set memory policy
> +                if (tc->from_node == NONE)
> +                        TEST(rc = syscall(__NR_set_mempolicy, tc->policy, NULL, 0));
> +                else
> +                        TEST(rc = syscall(__NR_set_mempolicy, tc->policy,&nodemask, maxnode));
> +
> +		if (TEST_RETURN < 0) {
> +			tst_resm(TFAIL, "set_mempolicy() failed - errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        result = 1;
> +			cleanup();
> +                        tst_exit();
> +                }
> +                break;
> +        default:
> +                flags = MPOL_F_ADDR;
> +                // mmap memory
> +                p = mmap(NULL, len, PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
> +                if (p == (void*)-1) {
> +			tst_resm(TFAIL, "malloc failed - errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        result = 1;
> +			cleanup();
> +                        tst_exit();
> +                }
> +                // set memory policy
> +                if (tc->from_node == NONE)
> +                        TEST(rc = syscall(__NR_mbind, p, len, tc->policy,NULL, 0, 0));
> +                else
> +                        TEST(rc = syscall(__NR_mbind, p, len, tc->policy,&nodemask, maxnode, 0));
> +                if (tc->ttype == INVALID_POINTER)
> +                        p = NULL;
> +
> +		if (tc->ttype == INVALID_FLAGS){
> +                        flags = -1;
> +                	break;
> +        	}
> +	}
> +        /*
> +         * Execute system call
> +         */
> +        errno = 0;
> +        TEST(sys_ret = syscall(__NR_get_mempolicy, &policy, &getnodemask, maxnode,p, flags));
> +        sys_errno = errno;
> +        if (sys_ret < 0)
> +                goto TEST_END;
> +
> +        // When policy equals MPOL_DEFAULT, then get_mempolicy not return node
> +        if (tc->policy == MPOL_DEFAULT)
> +                nodemask_zero(&nodemask);
> +        cmp_ok = tc->policy == policy && nodemask_equal(&nodemask,&getnodemask);
> +        if (opt_debug) {
> +                nodemask_dump("nodemask Expect:", &nodemask);
> +                nodemask_dump("nodemask Result:", &getnodemask);
> +                tst_resm(TINFO,"policy E:%d R:%d", tc->policy, policy);
> +        }
> +TEST_END:
> +        /*
> +         * Check results
> +         */
> +        result |= (sys_errno != tc->err) || !cmp_ok;
> +        PRINT_RESULT_CMP(0, tc->ret, tc->err, sys_ret, sys_errno, cmp_ok);
> +EXIT:
> +        return result;
> +}
> +
> +
> +/*
> + * usage()
> + */
> +
> +void usage(const char *progname)
> +{
> +        tst_resm(TINFO,"usage: %s [options]", progname);
> +        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
> +        tst_resm(TINFO,"options:");
> +        tst_resm(TINFO,"    -d --debug           Show debug messages");
> +        tst_resm(TINFO,"    -h --help            Show this message");
> +
> +        tst_resm(TINFO,"NG");
> +        exit(1);
> +}
> +
> +
> +/*
> + * main()
> + */
> +
> +
> +
> +int main(int ac, char **av) {
> +	int result = RESULT_OK;
> +        int c;
> +        int i;
> +        int lc;                 /* loop counter */
> +        char *msg;              /* message returned from parse_opts */
> +
> +	struct option long_options[] = {
> +                { "debug", no_argument, 0, 'd' },
> +                { "help",  no_argument, 0, 'h' },
> +                { NULL, 0, NULL, 0 }
> +        };
> +
> +	progname = strchr(av[0], '/');
> +        progname = progname ? progname + 1 : av[0];	
> +	
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> +
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
> +			 while(TEST_RETURN != -1) {
> +		                switch (c) {
> +                		case 'd':
> +		                        opt_debug = 1;
> +                		        break;
> +		                default:
> +                		        usage(progname);
> +                        		// NOTREACHED
> +                		}
> +		        }
> +
> +		/*
> +		* Execute test
> +         	*/
> +	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
> +        	        int ret;
> +	                tst_resm(TINFO,"(case%02d) START", i);
> +	                ret = do_test(&tcase[i]);
> +	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
> +	                result |= ret;
> +        	}
> +		
> +		/*
> +        	 * Check results
> +         	*/
> +        	switch(result) {
> +	        case RESULT_OK:
> +        			tst_resm(TPASS, "get_mempolicy call succeeded");
> +		                break;
> +
> +	        default:
> +                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
> +        		        tst_resm(TINFO,"NG");
> +				cleanup();
> +				tst_exit();
> +		                break;
> +        	}
> +	
> +	     }
> +
> +          }
> +        cleanup();
> +	tst_exit();
> +}
> +
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/get_mempolicy/Makefile	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/get_mempolicy/Makefile	2009-05-22 23:56:55.000000000 +0530
> @@ -0,0 +1,31 @@
> +#
> +#  Copyright (c) International Business Machines  Corp., 2009
> +#
> +#  This program is free software;  you can redistribute it and/or modify
> +#  it under the terms of the GNU General Public License as published by
> +#  the Free Software Foundation; either version 2 of the License, or
> +#  (at your option) any later version.
> +#
> +#  This program is distributed in the hope that it will be useful,
> +#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
> +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> +#  the GNU General Public License for more details.
> +#
> +#  You should have received a copy of the GNU General Public License
> +#  along with this program;  if not, write to the Free Software
> +#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#
> +
> +CFLAGS += -I../../../../include -Wall -O2
> +LDLIBS += -L../../../../lib -lltp 
> +
> +SRCS    = $(wildcard *.c)
> +TARGETS = $(patsubst %.c,%,$(SRCS))
> +
> +all: $(TARGETS)
> +
> +install:
> +	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
> +
> +clean:
> +	rm -f $(TARGETS)
> --- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-26 21:12:52.000000000 +0530
> +++ ltp-intermediate-20090521/runtest/syscalls	2009-05-26 21:34:34.000000000 +0530
> @@ -393,6 +393,7 @@ getresuid03 getresuid03
>  getrlimit01 getrlimit01
>  getrlimit02 getrlimit02
> 
> +get_mempolicy01 get_mempolicy01
>  get_robust_list01 get_robust_list01
> 
>  getrusage01 getrusage01
> 
> ---
> Regards--
> Manas
> 


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [LTP] [PATCH 03/13] Add/Port clock_getres01 test for clock_getres() syscall
  2009-05-27 10:08 ` [LTP] [PATCH 03/13] Add/Port clock_getres01 test for clock_getres() syscall Manas Kumar Nayak
@ 2009-05-29 12:56   ` Subrata Modak
  0 siblings, 0 replies; 31+ messages in thread
From: Subrata Modak @ 2009-05-29 12:56 UTC (permalink / raw)
  To: Manas Kumar Nayak; +Cc: LTP List

On Wed, 2009-05-27 at 15:38 +0530, Manas Kumar Nayak wrote: 
> Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>

Thanks.

Regards--
Subrata

> To: LTP List <ltp-list@lists.sourceforge.net>
> Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
> Cc: Masatake YAMATO <yamato@redhat.com>
> ---
> 
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/clock_getres/clock_getres01.c	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/clock_getres/clock_getres01.c	2009-05-27 12:15:45.000000000 +0530
> @@ -0,0 +1,344 @@
> +/******************************************************************************/
> +/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
> +/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
> +/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
> +/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
> +/*                                                                  	      */
> +/* This program is free software;  you can redistribute it and/or modify      */
> +/* it under the terms of the GNU General Public License as published by       */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> +/*                                                                            */
> +/******************************************************************************/
> +/******************************************************************************/
> +/*                                                                            */
> +/* File:        clock_getres01.c                                              */
> +/*                                                                            */
> +/* Description: This tests the clock_getres() syscall                         */
> +/*									      */
> +/* 									      */
> +/*									      */
> +/*									      */
> +/*									      */
> +/*                                                                            */
> +/* Usage:  <for command-line>                                                 */
> +/* clock_getres01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                        */
> +/*      where,  -c n : Run n copies concurrently.                             */
> +/*              -e   : Turn on errno logging.                                 */
> +/*              -i n : Execute test n times.                                  */
> +/*              -I x : Execute test for x seconds.                            */
> +/*              -P x : Pause for x seconds between iterations.                */
> +/*              -t   : Turn on syscall timing.                                */
> +/*                                                                            */
> +/* Total Tests: 1                                                             */
> +/*                                                                            */
> +/* Test Name:   clock_getres01                                                */
> +/* History:     Porting from Crackerjack to LTP is done by                    */
> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
> +/******************************************************************************/
> +#include <sys/syscall.h>
> +#include <sys/types.h>
> +#include <getopt.h>
> +#include <string.h>
> +#include <stdlib.h>
> +#include <errno.h>
> +#include <stdio.h>
> +#include <time.h>
> +
> +
> +#include "../utils/include_j_h.h"
> +
> +/* Harness Specific Include Files. */
> +#include "test.h"
> +#include "usctest.h"
> +#include "linux_syscall_numbers.h"
> +
> +/* Extern Global Variables */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> +
> +/* Global Variables */
> +char *TCID = "clock_getres01";  /* Test program identifier.*/
> +int  testno;
> +int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
> +
> +/* Extern Global Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    cleanup                                                       */
> +/*                                                                            */
> +/* Description: Performs all one time clean up for this test on successful    */
> +/*              completion,  premature exit or  failure. Closes all temporary */
> +/*              files, removes all temporary directories exits the test with  */
> +/*              appropriate return code by calling tst_exit() function.       */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> +/*              On success - Exits calling tst_exit(). With '0' return code.  */
> +/*                                                                            */
> +/******************************************************************************/
> +extern void cleanup() {
> +        /* Remove tmp dir and all files in it */
> +        TEST_CLEANUP;
> +        tst_rmdir();
> +
> +        /* Exit with appropriate return code. */
> +        tst_exit();
> +}
> +
> +/* Local  Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    setup                                                         */
> +/*                                                                            */
> +/* Description: Performs all one time setup for this test. This function is   */
> +/*              typically used to capture signals, create temporary dirs      */
> +/*              and temporary files that may be used in the course of this    */
> +/*              test.                                                         */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits by calling cleanup().                      */
> +/*              On success - returns 0.                                       */
> +/*                                                                            */
> +/******************************************************************************/
> +void setup() {
> +        /* Capture signals if any */
> +        /* Create temporary directories */
> +        TEST_PAUSE;
> +        tst_tmpdir();
> +}
> +
> +
> +/*
> + * Macros
> + */
> +#define SYSCALL_NAME    "clock_getres"
> +
> +
> +/*
> + * Global variables
> + */
> +static int opt_debug;
> +static char *progname;
> +
> +enum test_type {
> +		NORMAL,
> +		NULL_POINTER,
> +};
> +
> +
> +/*
> + * Data Structure
> + */
> +struct test_case {
> +	clockid_t clk_id;
> +        int ttype;
> +        int ret;
> +        int err;
> +};
> +
> +
> +/* Test cases
> +*
> +*   test status of errors on man page
> +*
> +*   EPERM   can't check because clock_getres not requires permission
> +*   EINVAL  v (not supported clk_id)
> +*/
> +
> +static struct test_case tcase[] = {
> +        { // case00
> +                .clk_id         = CLOCK_REALTIME,
> +                .ttype          = NORMAL,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case01
> +                .clk_id         = CLOCK_MONOTONIC,
> +                .ttype          = NORMAL,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case02
> +                .clk_id         = CLOCK_PROCESS_CPUTIME_ID,
> +                .ttype          = NORMAL,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case03
> +                .clk_id         = CLOCK_THREAD_CPUTIME_ID,
> +                .ttype          = NORMAL,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case04
> +                .clk_id         = -1,
> +                .ttype          = NORMAL,
> +                .ret            = -1,
> +                .err            = EINVAL,
> +        },
> +        { // case05
> +                .clk_id         = CLOCK_REALTIME,
> +                .ttype          = NULL_POINTER,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +};
> +
> +
> +
> +
> +#define MEM_LENGTH              (4 * 1024 * 1024)
> +/*
> + * do_test()
> + *
> + *   Input  : TestCase Data
> + *   Return : RESULT_OK(0), RESULT_NG(1)
> + *
> + */
> +
> +static int do_test(struct test_case *tc)
> +{
> +        int sys_ret;
> +        int sys_errno;
> +        int result = RESULT_OK;
> +	struct timespec res;
> +
> +	/*
> +         * Execute system call
> +         */
> +        errno = 0;
> +        if (tc->ttype == NULL_POINTER)
> +                TEST(sys_ret = clock_getres(tc->clk_id, NULL));
> +        else
> +                TEST(sys_ret = clock_getres(tc->clk_id, &res));
> +        sys_errno = errno;
> +
> +        /*
> +         * Check results
> +         */
> +        result |= (sys_errno != tc->err);
> +        PRINT_RESULT(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno);
> +
> +        return result;
> +}
> +
> +
> +/*
> + * usage()
> + */
> +
> +static void usage(const char *progname)
> +{
> +        tst_resm(TINFO,"usage: %s [options]", progname);
> +        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
> +        tst_resm(TINFO,"options:");
> +        tst_resm(TINFO,"    -d --debug           Show debug messages");
> +        tst_resm(TINFO,"    -h --help            Show this message");
> +
> +        tst_resm(TINFO,"NG");
> +        exit(1);
> +}
> +
> +
> +/*
> + * main()
> + */
> +
> +
> +
> +int main(int ac, char **av) {
> +	int result = RESULT_OK;
> +        int c;
> +        int i;
> +        int lc;                 /* loop counter */
> +        char *msg;              /* message returned from parse_opts */
> +
> +	struct option long_options[] = {
> +                { "debug", no_argument, 0, 'd' },
> +                { "help",  no_argument, 0, 'h' },
> +                { NULL, 0, NULL, 0 }
> +        };
> +
> +	progname = strchr(av[0], '/');
> +        progname = progname ? progname + 1 : av[0];	
> +	
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> +
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
> +			 while(TEST_RETURN != -1) {
> +		                switch (c) {
> +                		case 'd':
> +		                        opt_debug = 1;
> +                		        break;
> +		                default:
> +                		        usage(progname);
> +                        		// NOTREACHED
> +                		}
> +		        }
> +
> +
> +		if (ac != optind) {
> +        	        tst_resm(TINFO,"Options are not match.");
> +                	usage(progname);
> +                	// NOTREACHED
> +	        }
> +
> +		/*
> +		* Execute test
> +         	*/
> +	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
> +        	        int ret;
> +	                tst_resm(TINFO,"(case%02d) START", i);
> +	                ret = do_test(&tcase[i]);
> +	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
> +	                result |= ret;
> +        	}
> +		
> +		/*
> +        	 * Check results
> +         	*/
> +        	switch(result) {
> +	        case RESULT_OK:
> +        			tst_resm(TPASS, "clock_getres call succeeded");
> +		                break;
> +
> +	        default:
> +                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
> +        		        RPRINTF("NG\n");
> +				cleanup();
> +				tst_exit();
> +		                break;
> +        	}
> +
> +                }
> +        }	
> +        cleanup();
> +	tst_exit();
> +}
> +
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/clock_getres/Makefile	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/clock_getres/Makefile	2009-05-22 23:43:27.000000000 +0530
> @@ -0,0 +1,31 @@
> +#
> +#  Copyright (c) International Business Machines  Corp., 2009
> +#
> +#  This program is free software;  you can redistribute it and/or modify
> +#  it under the terms of the GNU General Public License as published by
> +#  the Free Software Foundation; either version 2 of the License, or
> +#  (at your option) any later version.
> +#
> +#  This program is distributed in the hope that it will be useful,
> +#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
> +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> +#  the GNU General Public License for more details.
> +#
> +#  You should have received a copy of the GNU General Public License
> +#  along with this program;  if not, write to the Free Software
> +#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#
> +
> +CFLAGS += -I../../../../include -Wall -O2
> +LDLIBS += -L../../../../lib -lltp -lrt
> +
> +SRCS    = $(wildcard *.c)
> +TARGETS = $(patsubst %.c,%,$(SRCS))
> +
> +all: $(TARGETS)
> +
> +install:
> +	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
> +
> +clean:
> +	rm -f $(TARGETS)
> --- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 12:11:54.000000000 +0530
> +++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 12:18:36.000000000 +0530
> @@ -74,6 +74,7 @@ chroot02 chroot02
>  chroot03 chroot03
>  chroot04 chroot04
> 
> +clock_getres01 clock_getres01
>  clock_nanosleep2_01 clock_nanosleep2_01
> 
>  clone01 clone01
> 
> ---
> Regards--
> Manas
> 


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [LTP] [PATCH 04/13] Add/Port clock_nanosleep01 test for clock_nanosleep() syscall
  2009-05-27 10:08 ` [LTP] [PATCH 04/13] Add/Port clock_nanosleep01 test for clock_nanosleep() syscall Manas Kumar Nayak
@ 2009-05-29 12:56   ` Subrata Modak
  0 siblings, 0 replies; 31+ messages in thread
From: Subrata Modak @ 2009-05-29 12:56 UTC (permalink / raw)
  To: Manas Kumar Nayak; +Cc: LTP List

On Wed, 2009-05-27 at 15:38 +0530, Manas Kumar Nayak wrote: 
> Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>

Thanks.

Regards--
Subrata

> To: LTP List <ltp-list@lists.sourceforge.net>
> Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
> Cc: Masatake YAMATO <yamato@redhat.com>
> ---
> 
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c	2009-05-27 12:29:23.000000000 +0530
> @@ -0,0 +1,470 @@
> +/******************************************************************************/
> +/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
> +/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
> +/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
> +/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
> +/*                                                                  	      */
> +/* This program is free software;  you can redistribute it and/or modify      */
> +/* it under the terms of the GNU General Public License as published by       */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> +/*                                                                            */
> +/******************************************************************************/
> +/******************************************************************************/
> +/*                                                                            */
> +/* File:        clock_nanosleep01.c                                           */
> +/*                                                                            */
> +/* Description: This tests the clock_nanosleep() syscall                      */
> +/*									      */
> +/* 									      */
> +/*									      */
> +/*									      */
> +/*									      */
> +/*                                                                            */
> +/* Usage:  <for command-line>                                                 */
> +/* clock_nanosleep01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                     */
> +/*      where,  -c n : Run n copies concurrently.                             */
> +/*              -e   : Turn on errno logging.                                 */
> +/*              -i n : Execute test n times.                                  */
> +/*              -I x : Execute test for x seconds.                            */
> +/*              -P x : Pause for x seconds between iterations.                */
> +/*              -t   : Turn on syscall timing.                                */
> +/*                                                                            */
> +/* Total Tests: 1                                                             */
> +/*                                                                            */
> +/* Test Name:   clock_nanosleep01                                             */
> +/* History:     Porting from Crackerjack to LTP is done by                    */
> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
> +/******************************************************************************/
> +#include <sys/syscall.h>
> +#include <sys/types.h>
> +#include <getopt.h>
> +#include <string.h>
> +#include <stdlib.h>
> +#include <errno.h>
> +#include <stdio.h>
> +#include <time.h>
> +#include <signal.h>
> +#include "../utils/common_j_h.c"
> +#include "../utils/include_j_h.h"
> +
> +/* Harness Specific Include Files. */
> +#include "test.h"
> +#include "usctest.h"
> +#include "linux_syscall_numbers.h"
> +
> +/* Extern Global Variables */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> +
> +/* Global Variables */
> +char *TCID = "clock_nanosleep01";  /* Test program identifier.*/
> +int  testno;
> +int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
> +
> +/* Extern Global Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    cleanup                                                       */
> +/*                                                                            */
> +/* Description: Performs all one time clean up for this test on successful    */
> +/*              completion,  premature exit or  failure. Closes all temporary */
> +/*              files, removes all temporary directories exits the test with  */
> +/*              appropriate return code by calling tst_exit() function.       */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> +/*              On success - Exits calling tst_exit(). With '0' return code.  */
> +/*                                                                            */
> +/******************************************************************************/
> +extern void cleanup() {
> +        /* Remove tmp dir and all files in it */
> +        TEST_CLEANUP;
> +        tst_rmdir();
> +
> +        /* Exit with appropriate return code. */
> +        tst_exit();
> +}
> +
> +/* Local  Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    setup                                                         */
> +/*                                                                            */
> +/* Description: Performs all one time setup for this test. This function is   */
> +/*              typically used to capture signals, create temporary dirs      */
> +/*              and temporary files that may be used in the course of this    */
> +/*              test.                                                         */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits by calling cleanup().                      */
> +/*              On success - returns 0.                                       */
> +/*                                                                            */
> +/******************************************************************************/
> +void setup() {
> +        /* Capture signals if any */
> +        /* Create temporary directories */
> +        TEST_PAUSE;
> +        tst_tmpdir();
> +}
> +
> +
> +/*
> + * Macros
> + */
> +#define SYSCALL_NAME    "clock_nanosleep"
> +
> +
> +/*
> + * Global variables
> + */
> +static int opt_debug;
> +static char *progname;
> +
> +enum test_type {
> +		NORMAL,
> +		NULL_POINTER,
> +		SEND_SIGINT,
> +};
> +
> +
> +/*
> + * Data Structure
> + */
> +struct test_case {
> +	clockid_t clk_id;
> +	int ttype;
> +        int flags;
> +        time_t sec;
> +        long nsec;
> +	int ret;
> +        int err;
> +};
> +
> +
> +/* Test cases
> + *
> + *   test status of errors on man page
> + *
> + *   EINTR              v (function was interrupted by a signal)
> + *   EINVAL             v (invalid tv_nsec, etc.)
> + *   ENOTSUP            can't check because not supported clk_id generates
> + *                      EINVAL
> + */
> +
> +
> +static struct test_case tcase[] = {
> +        { // case00
> +                .clk_id         = CLOCK_REALTIME,
> +                .ttype          = NORMAL,
> +		.flags          = 0,
> +                .sec            = 0,
> +                .nsec           = 500000000, // 500msec
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case01
> +                .clk_id         = CLOCK_MONOTONIC,
> +                .ttype          = NORMAL,
> +		.flags          = 0,
> +                .sec            = 0,
> +                .nsec           = 500000000, // 500msec
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +	{ // case02
> +                .ttype          = NORMAL,
> +                .clk_id         = CLOCK_REALTIME,
> +                .flags          = 0,
> +                .sec            = 0,
> +                .nsec           = -1,   // invalid
> +                .ret            = EINVAL,
> +                .err            = 0,
> +        },
> +        { // case03
> +                .ttype          = NORMAL,
> +                .clk_id         = CLOCK_REALTIME,
> +                .flags          = 0,
> +                .sec            = 0,
> +                .nsec           = 1000000000,   // invalid
> +                .ret            = EINVAL,
> +                .err            = 0,
> +        },
> +        { // case04
> +                .ttype          = NORMAL,
> +                .clk_id         = CLOCK_THREAD_CPUTIME_ID, // not supported
> +                .flags          = 0,
> +                .sec            = 0,
> +                .nsec           = 500000000, // 500msec
> +                .ret            = ENOTSUP, // RHEL4U1 + 2.6.18 returns EINVAL
> +                .err            = 0,
> +        },
> +        { // case05
> +                .ttype          = SEND_SIGINT,
> +                .clk_id         = CLOCK_REALTIME,
> +                .flags          = 0,
> +                .sec            = 10,
> +                .nsec           = 0,
> +                .ret            = EINTR,
> +                .err            = 0,
> +        },
> +#if 0   // glibc generates SEGV error (RHEL4U1 + 2.6.18)
> +        { // caseXX
> +                .ttype          = NULL_POINTER,
> +                .clk_id         = CLOCK_REALTIME,
> +                .flags          = 0,
> +                .sec            = 0,
> +                .nsec           = 500000000, // 500msec
> +                .ret            = EFAULT,
> +                .err            = 0,
> +        },
> +#endif
> +};
> +
> +
> +/*
> + * chk_difftime()
> + *   Return : OK(0), NG(-1)
> + */
> +#define MAX_MSEC_DIFF   20
> +
> +static int chk_difftime(struct timespec *bef, struct timespec *aft,
> +                        time_t sec, long nsec)
> +{
> +        struct timespec t;
> +        time_t expect;
> +        time_t result;
> +
> +        t.tv_sec = aft->tv_sec - bef->tv_sec;
> +        t.tv_nsec = aft->tv_nsec - bef->tv_nsec;
> +        if (t.tv_nsec < 0) {
> +                t.tv_sec -= 1;
> +                t.tv_nsec += 1000000000;
> +        }
> +        TEST(expect = (sec * 1000) + (nsec / 1000000));
> +        TEST(result = (t.tv_sec * 1000) + (t.tv_nsec / 1000000));
> +        tst_resm(TINFO,"check sleep time: (min:%ld) < %ld < (max:%ld) (msec)",expect - MAX_MSEC_DIFF, result, expect + MAX_MSEC_DIFF);
> +        if (result < expect - MAX_MSEC_DIFF || result > expect + MAX_MSEC_DIFF)
> +                return -1;
> +	return 0;
> +}
> +
> +
> +/*
> + * do_test()
> + *
> + *   Input  : TestCase Data
> + *   Return : RESULT_OK(0), RESULT_NG(1)
> + *
> + */
> +static int do_test(struct test_case *tc)
> +{
> +        int sys_ret;
> +        int sys_errno;
> +        int result = RESULT_OK;
> +        struct timespec beftp, afttp, rq, rm;
> +        int rc, range_ok = 1, remain_ok = 1;
> +        pid_t pid = 0;
> +
> +	 /*
> +         * Check before sleep time
> +         */
> +        if (tc->ttype == SEND_SIGINT) {
> +                TEST(pid = create_sig_proc(500000, SIGINT));
> +                if (TEST_RETURN < 0)
> +                        return 1;
> +        }
> +
> +        /*
> +         * Check before sleep time
> +         */
> +        TEST(rc = clock_gettime(tc->clk_id, &beftp));
> +        if (rc < 0) {
> +                tst_resm(TFAIL, "iclock_gettime failed - errno = %d : %s", TEST_ERRNO, strerror(TEST_ERRNO));
> +                result = 1;
> +                goto EXIT;
> +        }
> +	 /*
> +         * Execute system call
> +         */
> +        rq.tv_sec = tc->sec;
> +        rq.tv_nsec = tc->nsec;
> +        // !!!CAUTION: 'clock_gettime' returns errno itself
> +        errno = 0;
> +        if (tc->ttype == NULL_POINTER)
> +                TEST(sys_ret = clock_nanosleep(tc->clk_id, tc->flags, NULL, &rm));
> +        else
> +                TEST(sys_ret = clock_nanosleep(tc->clk_id, tc->flags, &rq, &rm));
> +        sys_errno = errno;
> +        if (sys_ret != 0)
> +                goto TEST_END;
> +	
> +	 /*
> +         * Check after sleep time
> +         */
> +        TEST(rc = clock_gettime(tc->clk_id, &afttp));
> +        if (TEST_RETURN < 0) {
> +                EPRINTF("clock_gettime failed.\n");
> +                result = 1;
> +                goto EXIT;
> +        }
> +	range_ok = chk_difftime(&beftp, &afttp, tc->sec, tc->nsec) == 0;
> +	/*
> +         * Check remaining time
> +         */
> +TEST_END:
> +        if (tc->ttype == NORMAL || tc->ttype == SEND_SIGINT) {
> +                tst_resm(TINFO,"remain time: %ld %ld", rm.tv_sec, rm.tv_nsec);
> +                if (tc->ttype == NORMAL)
> +                        remain_ok = rm.tv_sec == 0 && rm.tv_nsec == 0;
> +                else
> +                        remain_ok = rm.tv_sec != 0 || rm.tv_nsec != 0;
> +        }
> +
> +	/*
> +         * Check results
> +         */
> +        result |= (sys_ret != tc->ret) || !range_ok || !remain_ok;
> +        if (!range_ok)
> +                PRINT_RESULT_EXTRA(0, tc->ret, tc->err, sys_ret, sys_errno,"time range check", range_ok);
> +        else
> +                PRINT_RESULT_EXTRA(0, tc->ret, tc->err, sys_ret, sys_errno,"remain time check", remain_ok);
> +EXIT:
> +        if (pid > 0) {
> +                int st;
> +                TEST(kill(pid, SIGTERM));
> +                TEST(wait(&st));
> +        }
> +        return result;
> +}
> +
> +/*
> + * sighandler()
> + */
> +void sighandler(int sig)
> +{
> +        if (sig == SIGINT)
> +                return;
> +        // NOTREACHED
> +        return;
> +}
> +
> +
> +/*
> + * usage()
> + */
> +
> +static void usage(const char *progname)
> +{
> +        tst_resm(TINFO,"usage: %s [options]", progname);
> +        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
> +        tst_resm(TINFO,"options:");
> +        tst_resm(TINFO,"    -d --debug           Show debug messages");
> +        tst_resm(TINFO,"    -h --help            Show this message");
> +        tst_resm(TINFO,"NG");
> +        exit(1);
> +}
> +
> +
> +/*
> + * main()
> + */
> +
> +
> +
> +int main(int ac, char **av) {
> +	int result = RESULT_OK;
> +        int c;
> +        int i;
> +        int lc;                 /* loop counter */
> +        char *msg;              /* message returned from parse_opts */
> +
> +	struct option long_options[] = {
> +                { "debug", no_argument, 0, 'd' },
> +                { "help",  no_argument, 0, 'h' },
> +                { NULL, 0, NULL, 0 }
> +        };
> +
> +	progname = strchr(av[0], '/');
> +        progname = progname ? progname + 1 : av[0];	
> +	
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> +
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
> +			 while(TEST_RETURN != -1) {
> +		                switch (c) {
> +                		case 'd':
> +		                        opt_debug = 1;
> +                		        break;
> +		                default:
> +                		        usage(progname);
> +                        		// NOTREACHED
> +                		}
> +		        }
> +
> +
> +		if (ac != optind) {
> +        	        tst_resm(TINFO,"Options are not match.");
> +                	usage(progname);
> +                	// NOTREACHED
> +	        }
> +
> +		/*
> +		* Execute test
> +         	*/
> +		TEST(signal(SIGINT, sighandler));
> +	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
> +        	        int ret;
> +	                tst_resm(TINFO,"(case%02d) START", i);
> +	                ret = do_test(&tcase[i]);
> +	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
> +	                result |= ret;
> +        	}
> +		
> +		/*
> +        	 * Check results
> +         	*/
> +        	switch(result) {
> +	        case RESULT_OK:
> +        			tst_resm(TPASS, "clock_nanosleep call succeeded");
> +		                break;
> +
> +	        default:
> +                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
> +        		        tst_resm(TINFO,"NG");
> +				cleanup();
> +				tst_exit();
> +		                break;
> +        	}
> +
> +                }
> +        }	
> +        cleanup();
> +	tst_exit();
> +}
> +
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/clock_nanosleep/Makefile	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/clock_nanosleep/Makefile	2009-05-23 09:41:29.000000000 +0530
> @@ -0,0 +1,31 @@
> +#
> +#  Copyright (c) International Business Machines  Corp., 2009
> +#
> +#  This program is free software;  you can redistribute it and/or modify
> +#  it under the terms of the GNU General Public License as published by
> +#  the Free Software Foundation; either version 2 of the License, or
> +#  (at your option) any later version.
> +#
> +#  This program is distributed in the hope that it will be useful,
> +#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
> +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> +#  the GNU General Public License for more details.
> +#
> +#  You should have received a copy of the GNU General Public License
> +#  along with this program;  if not, write to the Free Software
> +#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#
> +
> +CFLAGS += -I../../../../include -Wall -O2
> +LDLIBS += -L../../../../lib -lltp -lrt
> +
> +SRCS    = $(wildcard *.c)
> +TARGETS = $(patsubst %.c,%,$(SRCS))
> +
> +all: $(TARGETS)
> +
> +install:
> +	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
> +
> +clean:
> +	rm -f $(TARGETS)
> --- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 12:22:30.000000000 +0530
> +++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 12:37:07.000000000 +0530
> @@ -75,6 +75,7 @@ chroot03 chroot03
>  chroot04 chroot04
> 
>  clock_getres01 clock_getres01
> +clock_nanosleep01 clock_nanosleep01
>  clock_nanosleep2_01 clock_nanosleep2_01
> 
>  clone01 clone01
> 
> ---
> Regards--
> Manas
> 


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [LTP] [PATCH 05/13] Add/Port mq_notify01 test for mq_notify() syscall
  2009-05-27 10:09 ` [LTP] [PATCH 05/13] Add/Port mq_notify01 test for mq_notify() syscall Manas Kumar Nayak
@ 2009-05-29 12:56   ` Subrata Modak
  0 siblings, 0 replies; 31+ messages in thread
From: Subrata Modak @ 2009-05-29 12:56 UTC (permalink / raw)
  To: Manas Kumar Nayak; +Cc: LTP List

On Wed, 2009-05-27 at 15:39 +0530, Manas Kumar Nayak wrote: 
> Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>

Thanks.

Regards--
Subrata

> To: LTP List <ltp-list@lists.sourceforge.net>
> Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
> Cc: Masatake YAMATO <yamato@redhat.com>
> ---
> 
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_notify/Makefile	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_notify/Makefile	2009-05-23 11:08:05.000000000 +0530
> @@ -0,0 +1,31 @@
> +#
> +#  Copyright (c) International Business Machines  Corp., 2009
> +#
> +#  This program is free software;  you can redistribute it and/or modify
> +#  it under the terms of the GNU General Public License as published by
> +#  the Free Software Foundation; either version 2 of the License, or
> +#  (at your option) any later version.
> +#
> +#  This program is distributed in the hope that it will be useful,
> +#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
> +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> +#  the GNU General Public License for more details.
> +#
> +#  You should have received a copy of the GNU General Public License
> +#  along with this program;  if not, write to the Free Software
> +#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#
> +
> +CFLAGS += -I../../../../include -Wall -O2 -D_POSIX_C_SOURCE=$(shell getconf _POSIX_MESSAGE_PASSING)L
> +LDLIBS += -L../../../../lib -lltp -lrt
> +
> +SRCS    = $(wildcard *.c)
> +TARGETS = $(patsubst %.c,%,$(SRCS))
> +
> +all: $(TARGETS)
> +
> +install:
> +	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
> +
> +clean:
> +	rm -f $(TARGETS)
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_notify/mq_notify01.c	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_notify/mq_notify01.c	2009-05-27 12:49:33.000000000 +0530
> @@ -0,0 +1,477 @@
> +/******************************************************************************/
> +/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
> +/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
> +/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
> +/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
> +/*                                                                  	      */
> +/* This program is free software;  you can redistribute it and/or modify      */
> +/* it under the terms of the GNU General Public License as published by       */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> +/*                                                                            */
> +/******************************************************************************/
> +/******************************************************************************/
> +/*                                                                            */
> +/* File:        mq_notify01.c                                                 */
> +/*                                                                            */
> +/* Description: This tests the mq_notify() syscall                            */
> +/*									      */
> +/* 									      */
> +/*									      */
> +/*									      */
> +/*									      */
> +/*                                                                            */
> +/* Usage:  <for command-line>                                                 */
> +/* mq_notify01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                           */
> +/*      where,  -c n : Run n copies concurrently.                             */
> +/*              -e   : Turn on errno logging.                                 */
> +/*              -i n : Execute test n times.                                  */
> +/*              -I x : Execute test for x seconds.                            */
> +/*              -P x : Pause for x seconds between iterations.                */
> +/*              -t   : Turn on syscall timing.                                */
> +/*                                                                            */
> +/* Total Tests: 1                                                             */
> +/*                                                                            */
> +/* Test Name:   mq_notify01                                                   */
> +/* History:     Porting from Crackerjack to LTP is done by                    */
> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
> +/******************************************************************************/
> +#include <sys/syscall.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <sys/uio.h>
> +#include <getopt.h>
> +#include <stdlib.h>
> +#include <errno.h>
> +#include <stdio.h>
> +#include <unistd.h>
> +#include <string.h>
> +#include <mqueue.h>
> +#include <signal.h>
> +#include <limits.h>
> +
> +#include "../utils/include_j_h.h"
> +
> +/* Harness Specific Include Files. */
> +#include "test.h"
> +#include "usctest.h"
> +#include "linux_syscall_numbers.h"
> +
> +/* Extern Global Variables */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> +
> +/* Global Variables */
> +char *TCID = "mq_notify01";  /* Test program identifier.*/
> +int  testno;
> +int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
> +
> +/* Extern Global Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    cleanup                                                       */
> +/*                                                                            */
> +/* Description: Performs all one time clean up for this test on successful    */
> +/*              completion,  premature exit or  failure. Closes all temporary */
> +/*              files, removes all temporary directories exits the test with  */
> +/*              appropriate return code by calling tst_exit() function.       */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> +/*              On success - Exits calling tst_exit(). With '0' return code.  */
> +/*                                                                            */
> +/******************************************************************************/
> +extern void cleanup() {
> +        /* Remove tmp dir and all files in it */
> +        TEST_CLEANUP;
> +        tst_rmdir();
> +
> +        /* Exit with appropriate return code. */
> +        tst_exit();
> +}
> +
> +/* Local  Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    setup                                                         */
> +/*                                                                            */
> +/* Description: Performs all one time setup for this test. This function is   */
> +/*              typically used to capture signals, create temporary dirs      */
> +/*              and temporary files that may be used in the course of this    */
> +/*              test.                                                         */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits by calling cleanup().                      */
> +/*              On success - returns 0.                                       */
> +/*                                                                            */
> +/******************************************************************************/
> +void setup() {
> +        /* Capture signals if any */
> +        /* Create temporary directories */
> +        TEST_PAUSE;
> +        tst_tmpdir();
> +}
> +
> +
> +/*
> + * Macros
> + */
> +#define SYSCALL_NAME    "mq_notify"
> +
> +
> +/*
> + * Global variables
> + */
> +static int opt_debug;
> +static char *progname;
> +static int notified;
> +static int cmp_ok;
> +
> +
> +enum test_type {
> +		NORMAL,
> +		FD_NONE,
> +	        FD_NOT_EXIST,
> +        	FD_FILE,
> +	        ALREADY_REGISTERED,
> +};
> +
> +
> +/*
> + * Data Structure
> + */
> +struct test_case {
> +        int notify;
> +	int ttype;
> +        int ret;
> +        int err;
> +};
> +
> +#define MAX_MSGSIZE     8192
> +#define MSG_SIZE        16
> +#define USER_DATA       0x12345678
> +
> +
> +/* Test cases
> + *
> + *   test status of errors on man page
> + *
> + *   EBADF              v (not a valid descriptor)
> + *   EBUSY              v (process is already registered for notification)
> +*/
> +
> +
> +static struct test_case tcase[] = {
> +	{ // case00
> +                .ttype          = NORMAL,
> +                .notify         = SIGEV_NONE,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case01
> +                .ttype          = NORMAL,
> +                .notify         = SIGEV_SIGNAL,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case02
> +                .ttype          = NORMAL,
> +                .notify         = SIGEV_THREAD,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case03
> +                .ttype          = FD_NONE,
> +                .notify         = SIGEV_NONE,
> +                .ret            = -1,
> +                .err            = EBADF,
> +        },
> +        { // case04
> +                .ttype          = FD_NOT_EXIST,
> +                .notify         = SIGEV_NONE,
> +                .ret            = -1,
> +                .err            = EBADF,
> +        },
> +        { // case05
> +                .ttype          = FD_FILE,
> +                .notify         = SIGEV_NONE,
> +                .ret            = -1,
> +                .err            = EBADF,
> +        },
> +        { // case06
> +                .ttype          = ALREADY_REGISTERED,
> +                .notify         = SIGEV_NONE,
> +                .ret            = -1,
> +                .err            = EBUSY,
> +        },
> +};
> +
> +
> +static void sigfunc(int signo, siginfo_t *info, void *data)
> +{
> +        if (opt_debug) {
> +                tst_resm(TINFO,"si_code  E:%d,\tR:%d", info->si_code, SI_MESGQ);
> +                tst_resm(TINFO,"si_signo E:%d,\tR:%d", info->si_signo, SIGUSR1);
> +                tst_resm(TINFO,"si_value E:0x%x,\tR:0x%x", info->si_value.sival_int,USER_DATA);
> +                tst_resm(TINFO,"si_pid   E:%d,\tR:%d", info->si_pid, getpid());
> +                tst_resm(TINFO,"si_uid   E:%d,\tR:%d", info->si_uid, getuid());
> +        }
> +        cmp_ok = info->si_code == SI_MESGQ &&
> +                 info->si_signo == SIGUSR1 &&
> +                 info->si_value.sival_int == USER_DATA &&
> +                 info->si_pid == getpid() &&
> +                 info->si_uid == getuid();
> +        notified = 1;
> +}
> +
> +static void tfunc(union sigval sv)
> +{
> +        cmp_ok = sv.sival_int == USER_DATA;
> +        notified = 1;
> +}
> +
> +/*
> + * do_test()
> + *
> + *   Input  : TestCase Data
> + *   Return : RESULT_OK(0), RESULT_NG(1)
> + *
> + */
> +
> +static int do_test(struct test_case *tc)
> +{
> +        int sys_ret;
> +        int sys_errno;
> +        int result = RESULT_OK;
> +        int rc, i, fd = -1;
> +        struct sigevent ev;
> +        struct sigaction sigact;
> +        char smsg[MAX_MSGSIZE];
> +
> +        notified = cmp_ok = 1;
> +
> +        /*
> +         * When test ended with SIGTERM etc, mq discriptor is left remains.
> +         * So we delete it first.
> +         */
> +        TEST(mq_unlink(QUEUE_NAME));
> +
> +        switch (tc->ttype) {
> +        case FD_NOT_EXIST:
> +                fd = INT_MAX - 1;
> +                /* fallthrough */
> +	case FD_NONE:
> +                break;
> +        case FD_FILE:
> +                TEST(fd = open("/", O_RDONLY));
> +                if (TEST_RETURN < 0) {
> +                        tst_resm(TFAIL,"can't open \"/\".");
> +                        result = 1;
> +                        goto EXIT;
> +                }
> +                break;
> +        default:
> +                /*
> +                 * Open message queue
> +                 */
> +                TEST(fd = mq_open(QUEUE_NAME, O_CREAT|O_EXCL|O_RDWR, S_IRWXU, NULL));
> +                if (TEST_RETURN < 0) {
> +                        tst_resm(TFAIL,"mq_open failed errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        result = 1;
> +                        goto EXIT;
> +                }
> +        }
> +
> +	/*
> +         * Set up struct sigevent
> +         */
> +        ev.sigev_notify = tc->notify;
> +        switch (tc->notify) {
> +        case SIGEV_SIGNAL:
> +                notified = cmp_ok = 0;
> +                ev.sigev_signo = SIGUSR1;
> +                ev.sigev_value.sival_int = USER_DATA;
> +
> +                // set up the signal handler
> +                memset(&sigact, 0, sizeof(sigact));
> +                sigact.sa_sigaction = sigfunc;
> +                sigact.sa_flags = SA_SIGINFO;
> +                TEST(rc = sigaction(SIGUSR1, &sigact, NULL));
> +                break;
> +        case SIGEV_THREAD:
> +                notified = cmp_ok = 0;
> +                ev.sigev_notify_function = tfunc;
> +                ev.sigev_notify_attributes = NULL;
> +                ev.sigev_value.sival_int = USER_DATA;
> +                break;
> +        }
> +
> +	if (tc->ttype == ALREADY_REGISTERED) {
> +                TEST(rc = mq_notify(fd, &ev));
> +                if (TEST_RETURN < 0) {
> +                        tst_resm(TFAIL,"mq_notify failed errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        result = 1;
> +                        goto EXIT;
> +                }
> +        }
> +	
> +	/*
> +         * Execute system call
> +         */
> +        errno = 0;
> +        sys_ret = mq_notify(fd, &ev);
> +        sys_errno = errno;
> +        if (sys_ret < 0)
> +                goto TEST_END;
> +
> +	 /*
> +         * Prepare send message
> +         */
> +        for (i = 0; i < MSG_SIZE; i++)
> +                smsg[i] = i;
> +        TEST(rc = mq_timedsend(fd, smsg, MSG_SIZE, 0, NULL));
> +        if (rc < 0) {
> +                tst_resm(TFAIL,"mq_timedsend failed errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                result = 1;
> +                goto EXIT;
> +        }
> +
> +        while (!notified)
> +                usleep(10000);
> +
> +TEST_END:
> +        /*
> +         * Check results
> +         */
> +        result |= (sys_errno != tc->err) || !cmp_ok;
> +        PRINT_RESULT_CMP(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno,
> +                         cmp_ok);
> +
> +EXIT:
> +        if (fd >= 0) {
> +                close(fd);
> +                mq_unlink(QUEUE_NAME);
> +        }
> +
> +        return result;
> +}
> +	
> +
> +
> +/*
> + * usage()
> + */
> +
> +static void usage(const char *progname)
> +{
> +        tst_resm(TINFO,"usage: %s [options]", progname);
> +        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
> +        tst_resm(TINFO,"options:");
> +        tst_resm(TINFO,"    -d --debug           Show debug messages");
> +        tst_resm(TINFO,"    -h --help            Show this message");
> +        tst_resm(TINFO,"NG");
> +        exit(1);
> +}
> +
> +
> +/*
> + * main()
> + */
> +
> +
> +
> +int main(int ac, char **av) {
> +	int result = RESULT_OK;
> +        int c;
> +        int i;
> +        int lc;                 /* loop counter */
> +        char *msg;              /* message returned from parse_opts */
> +
> +	struct option long_options[] = {
> +                { "debug", no_argument, 0, 'd' },
> +                { "help",  no_argument, 0, 'h' },
> +                { NULL, 0, NULL, 0 }
> +        };
> +
> +	progname = strchr(av[0], '/');
> +        progname = progname ? progname + 1 : av[0];	
> +	
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> +
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
> +			 while(TEST_RETURN != -1) {
> +		                switch (c) {
> +                		case 'd':
> +		                        opt_debug = 1;
> +                		        break;
> +		                default:
> +                		        usage(progname);
> +                        		// NOTREACHED
> +                		}
> +		        }
> +
> +
> +		if (ac != optind) {
> +        	        tst_resm(TINFO,"Options are not match.");
> +                	usage(progname);
> +                	// NOTREACHED
> +	        }
> +
> +		/*
> +		* Execute test
> +         	*/
> +	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
> +        	        int ret;
> +	                tst_resm(TINFO,"(case%02d) START", i);
> +	                ret = do_test(&tcase[i]);
> +	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
> +	                result |= ret;
> +        	}
> +		
> +		/*
> +        	 * Check results
> +         	*/
> +        	switch(result) {
> +	        case RESULT_OK:
> +        			tst_resm(TPASS, "mq_notify call succeeded");
> +		                break;
> +
> +	        default:
> +                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
> +        		        tst_resm(TINFO,"NG");
> +				cleanup();
> +				tst_exit();
> +		                break;
> +        	}
> +
> +                }
> +        }	
> +        cleanup();
> +	tst_exit();
> +}
> +
> --- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 12:45:56.000000000 +0530
> +++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 12:55:31.000000000 +0530
> @@ -585,6 +585,8 @@ mprotect01 mprotect01
>  mprotect02 mprotect02
>  mprotect03 mprotect03
> 
> +mq_notify01 mq_notify01
> +
>  mremap01 mremap01
>  mremap02 mremap02
>  mremap03 mremap03
> 
> ---
> Regards--
> Manas
> 


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [LTP] [PATCH 06/13]  Add/Port ppoll01 test for ppoll() syscall
  2009-05-27 10:09 ` [LTP] [PATCH 06/13] Add/Port ppoll01 test for ppoll() syscall Manas Kumar Nayak
@ 2009-05-29 12:56   ` Subrata Modak
  2009-08-06  9:56     ` Michal Simek
  0 siblings, 1 reply; 31+ messages in thread
From: Subrata Modak @ 2009-05-29 12:56 UTC (permalink / raw)
  To: Manas Kumar Nayak; +Cc: LTP List

Thanks.

Regards--
Subrata

On Wed, 2009-05-27 at 15:39 +0530, Manas Kumar Nayak wrote: 
> diff -uprN ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/Makefile ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/Makefile
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/Makefile	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/Makefile	2009-05-23 12:01:25.000000000 +0530
> @@ -0,0 +1,31 @@
> +#
> +#  Copyright (c) International Business Machines  Corp., 2009
> +#
> +#  This program is free software;  you can redistribute it and/or modify
> +#  it under the terms of the GNU General Public License as published by
> +#  the Free Software Foundation; either version 2 of the License, or
> +#  (at your option) any later version.
> +#
> +#  This program is distributed in the hope that it will be useful,
> +#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
> +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> +#  the GNU General Public License for more details.
> +#
> +#  You should have received a copy of the GNU General Public License
> +#  along with this program;  if not, write to the Free Software
> +#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#
> +
> +CFLAGS += -I../../../../include -Wall -O2
> +LDLIBS += -L../../../../lib -lltp 
> +
> +SRCS    = $(wildcard *.c)
> +TARGETS = $(patsubst %.c,%,$(SRCS))
> +
> +all: $(TARGETS)
> +
> +install:
> +	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
> +
> +clean:
> +	rm -f $(TARGETS)
> diff -uprN ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/ppoll01.c ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/ppoll01.c
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/ppoll01.c	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/ppoll01.c	2009-05-27 13:00:58.000000000 +0530
> @@ -0,0 +1,482 @@
> +/******************************************************************************/
> +/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
> +/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
> +/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
> +/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
> +/*                                                                  	      */
> +/* This program is free software;  you can redistribute it and/or modify      */
> +/* it under the terms of the GNU General Public License as published by       */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> +/*                                                                            */
> +/******************************************************************************/
> +/******************************************************************************/
> +/*                                                                            */
> +/* File:        ppoll01.c                                                     */
> +/*                                                                            */
> +/* Description: This tests the ppoll01() syscall                              */
> +/*									      */
> +/* 									      */
> +/*									      */
> +/*									      */
> +/*									      */
> +/*                                                                            */
> +/* Usage:  <for command-line>                                                 */
> +/* ppoll01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                               */
> +/*      where,  -c n : Run n copies concurrently.                             */
> +/*              -e   : Turn on errno logging.                                 */
> +/*              -i n : Execute test n times.                                  */
> +/*              -I x : Execute test for x seconds.                            */
> +/*              -P x : Pause for x seconds between iterations.                */
> +/*              -t   : Turn on syscall timing.                                */
> +/*                                                                            */
> +/* Total Tests: 1                                                             */
> +/*                                                                            */
> +/* Test Name:   ppoll01                                                       */
> +/* History:     Porting from Crackerjack to LTP is done by                    */
> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
> +/******************************************************************************/
> +#include <sys/syscall.h>
> +#include <sys/types.h>
> +#include <sys/select.h>
> +#include <sys/wait.h>
> +#include <getopt.h>
> +#include <string.h>
> +#include <stdlib.h>
> +#include <errno.h>
> +#include <stdio.h>
> +#include <unistd.h>
> +#include <fcntl.h>
> +#include <libgen.h>
> +#include <limits.h>
> +#include <signal.h>
> +#include "asm/poll.h"
> +
> +
> +#include "../utils/include_j_h.h"
> +#include "../utils/common_j_h.c"
> +
> +/* Harness Specific Include Files. */
> +#include "test.h"
> +#include "usctest.h"
> +#include "linux_syscall_numbers.h"
> +
> +/* Extern Global Variables */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> +
> +/* Global Variables */
> +char *TCID = "ppoll01";  /* Test program identifier.*/
> +int  testno;
> +int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
> +
> +/* Extern Global Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    cleanup                                                       */
> +/*                                                                            */
> +/* Description: Performs all one time clean up for this test on successful    */
> +/*              completion,  premature exit or  failure. Closes all temporary */
> +/*              files, removes all temporary directories exits the test with  */
> +/*              appropriate return code by calling tst_exit() function.       */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> +/*              On success - Exits calling tst_exit(). With '0' return code.  */
> +/*                                                                            */
> +/******************************************************************************/
> +extern void cleanup() {
> +        /* Remove tmp dir and all files in it */
> +        TEST_CLEANUP;
> +        tst_rmdir();
> +
> +        /* Exit with appropriate return code. */
> +        tst_exit();
> +}
> +
> +/* Local  Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    setup                                                         */
> +/*                                                                            */
> +/* Description: Performs all one time setup for this test. This function is   */
> +/*              typically used to capture signals, create temporary dirs      */
> +/*              and temporary files that may be used in the course of this    */
> +/*              test.                                                         */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits by calling cleanup().                      */
> +/*              On success - returns 0.                                       */
> +/*                                                                            */
> +/******************************************************************************/
> +void setup() {
> +        /* Capture signals if any */
> +        /* Create temporary directories */
> +        TEST_PAUSE;
> +        tst_tmpdir();
> +}
> +
> +
> +/*
> + * Macros
> + */
> +#define SYSCALL_NAME    "ppoll"
> +
> +#ifndef __NR_ppoll
> +#  define __NR_ppoll    309
> +#endif
> +
> +#ifndef POLLRDHUP
> +#  define POLLRDHUP     0x2000
> +#endif
> +
> +
> +/*
> + * Global variables
> + */
> +static int opt_debug;
> +static char *progname;
> +static char *progdir;
> +
> +enum test_type {
> +	NORMAL,
> +        MASK_SIGNAL,
> +        TIMEOUT,
> +        FD_ALREADY_CLOSED,
> +        SEND_SIGINT,
> +        INVALID_NFDS,
> +        INVALID_FDS,
> +        MINUS_NSEC,
> +        TOO_LARGE_NSEC,
> +
> +};
> +
> +
> +/*
> + * Data Structure
> + */
> +struct test_case {
> +	short expect_revents;
> +        int ttype;
> +        int ret;
> +        int err;
> +};
> +
> +
> +/* Test cases
> + *
> + *   test status of errors on man page
> + *
> + *   EBADF              can't check because EBADF never happen even though
> + *                      fd was invalid. In this case, information of invalid
> + *                      fd is set in revents
> + *   EFAULT             v ('fds' array in the invalid address space)
> + *   EINTR              v (a non blocked signal was caught)
> + *   EINVAL             v ('nfds' is over the 'RLIMIT_NOFILE' value)
> + *   ENOMEM             can't check because it's difficult to create no-memory
> + */
> +
> +
> +static struct test_case tcase[] = {
> +	{ // case00
> +                .ttype          = NORMAL,
> +                .expect_revents = POLLOUT,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case01
> +                .ttype          = MASK_SIGNAL,
> +                .expect_revents = 0, // don't care
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case02
> +                .ttype          = TIMEOUT,
> +                .expect_revents = 0, // don't care
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case03
> +                .ttype          = FD_ALREADY_CLOSED,
> +                .expect_revents = POLLNVAL,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case04
> +                .ttype          = SEND_SIGINT,
> +                .ret            = -1,
> +                .err            = EINTR,
> +        },
> +        { // case05
> +                .ttype          = INVALID_NFDS,
> +                .ret            = -1,
> +                .err            = EINVAL,
> +        },
> +        { // case06
> +                .ttype          = INVALID_FDS,
> +                .ret            = -1,
> +                .err            = EFAULT,
> +        },
> +#if 0
> +        { // case07
> +                .ttype          = MINUS_NSEC,
> +                .ret            = -1,
> +                .err            = EINVAL, // RHEL4U1 + 2.6.18 returns SUCCESS
> +        },
> +        { // case08
> +                .ttype          = TOO_LARGE_NSEC,
> +                .ret            = -1,
> +                .err            = EINVAL, // RHEL4U1 + 2.6.18 returns SUCCESS
> +        },
> +#endif
> +};
> +
> +#define NUM_TEST_FDS    1
> +
> +/*
> + * do_test()
> + *
> + *   Input  : TestCase Data
> + *   Return : RESULT_OK(0), RESULT_NG(1)
> + *
> + */
> +
> +static int do_test(struct test_case *tc)
> +{
> +        int sys_ret;
> +        int sys_errno;
> +        int result = RESULT_OK;
> +	int fd = -1 , cmp_ok = 1;
> +	char fpath[PATH_MAX];
> +	struct pollfd *p_fds, fds[NUM_TEST_FDS];
> +        unsigned int nfds = NUM_TEST_FDS;
> +        struct timespec *p_ts, ts;
> +        sigset_t *p_sigmask, sigmask;
> +        size_t sigsetsize = 0;
> +        pid_t pid = 0;
> +
> +	TEST(fd = setup_file(progdir, "test.file", fpath));
> +        if (fd < 0)
> +                return 1;
> +        fds[0].fd = fd;
> +        fds[0].events = POLLIN | POLLPRI | POLLOUT | POLLRDHUP;
> +        fds[0].revents = 0;
> +        p_fds = fds;
> +        p_ts = NULL;
> +        p_sigmask = NULL;
> +
> +	switch (tc->ttype) {
> +        case TIMEOUT:
> +                nfds = 0;
> +                ts.tv_sec = 0;
> +                ts.tv_nsec = 50000000;  // 50msec
> +                p_ts = &ts;
> +                break;
> +	case FD_ALREADY_CLOSED:
> +                TEST(close(fd));
> +                fd = -1;
> +                TEST(cleanup_file(fpath));
> +                break;
> +        case MASK_SIGNAL:
> +                TEST(sigemptyset(&sigmask));
> +                TEST(sigaddset(&sigmask, SIGINT));
> +                p_sigmask = &sigmask;
> +                //sigsetsize = sizeof(sigmask);
> +                sigsetsize = 8;
> +                nfds = 0;
> +                ts.tv_sec = 0;
> +                ts.tv_nsec = 300000000; // 300msec => need to be enough for
> +                                        //   waiting the signal
> +                p_ts = &ts;
> +                // fallthrough
> +	case SEND_SIGINT:
> +                nfds = 0;
> +                TEST(pid = create_sig_proc(100000, SIGINT)); // 100msec
> +                if (pid < 0)
> +                        return 1;
> +                break;
> +        case INVALID_NFDS:
> +                //nfds = RLIMIT_NOFILE + 1; ==> RHEL4U1 + 2.6.18 returns SUCCESS
> +                nfds = -1;
> +                break;
> +        case INVALID_FDS:
> +                p_fds = (void*)0xc0000000;
> +                break;
> +        case MINUS_NSEC:
> +                ts.tv_sec = 0;
> +                ts.tv_nsec = -1;
> +                p_ts = &ts;
> +                break;
> +	case TOO_LARGE_NSEC:
> +                ts.tv_sec = 0;
> +                ts.tv_nsec = 1000000000;
> +                p_ts = &ts;
> +                break;
> +        }
> +
> +	/*
> +	   * Execute system call
> +         */
> +        errno = 0;
> +        TEST(sys_ret = syscall(__NR_ppoll, p_fds, nfds, p_ts, p_sigmask, sigsetsize));
> +        sys_errno = errno;
> +        if (sys_ret <= 0 || tc->ret < 0)
> +                goto TEST_END;
> +
> +        cmp_ok = fds[0].revents == tc->expect_revents;
> +        if (opt_debug) {
> +                tst_resm(TINFO,"EXPECT: revents=0x%04x", tc->expect_revents);
> +                tst_resm(TINFO,"RESULT: revents=0x%04x", fds[0].revents);
> +        }
> +
> +TEST_END:
> +        /*
> +         * Check results
> +         */
> +        result |= (sys_errno != tc->err) || !cmp_ok;
> +        PRINT_RESULT_CMP(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno,
> +                         cmp_ok);
> +
> +        if (fd >= 0)
> +                cleanup_file(fpath);
> +        if (pid > 0) {
> +                int st;
> +                kill(pid, SIGTERM);
> +                wait(&st);
> +        }
> +	return result;
> +}
> +
> +
> +/*
> + * sighandler()
> + */
> +void sighandler(int sig)
> +{
> +        if (sig == SIGINT)
> +                return;
> +        // NOTREACHED
> +        return;
> +}
> +
> +
> +/*
> + * usage()
> + */
> +
> +static void usage(const char *progname)
> +{
> +        tst_resm(TINFO,"usage: %s [options]", progname);
> +        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
> +        tst_resm(TINFO,"options:");
> +        tst_resm(TINFO,"    -d --debug           Show debug messages");
> +        tst_resm(TINFO,"    -h --help            Show this message");
> +        tst_resm(TINFO,"NG");
> +        exit(1);
> +}
> +
> +
> +/*
> + * main()
> + */
> +
> +
> +
> +int main(int ac, char **av) {
> +	int result = RESULT_OK;
> +        int c;
> +        int i;
> +        int lc;                 /* loop counter */
> +        char *msg;              /* message returned from parse_opts */
> +
> +	struct option long_options[] = {
> +                { "debug", no_argument, 0, 'd' },
> +                { "help",  no_argument, 0, 'h' },
> +                { NULL, 0, NULL, 0 }
> +        };
> +
> +	progname = strchr(av[0], '/');
> +        progname = progname ? progname + 1 : av[0];	
> +
> +	progdir = strdup(av[0]);
> +        progdir = dirname(progdir);
> +	
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> +
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
> +			 while(TEST_RETURN != -1) {
> +		                switch (c) {
> +                		case 'd':
> +		                        opt_debug = 1;
> +                		        break;
> +		                default:
> +                		        usage(progname);
> +                        		// NOTREACHED
> +                		}
> +		        }
> +
> +
> +		if (ac != optind) {
> +        	        tst_resm(TINFO,"Options are not match.");
> +                	usage(progname);
> +                	// NOTREACHED
> +	        }
> +
> +		/*
> +		* Execute test
> +         	*/
> +	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
> +        	        int ret;
> +	                tst_resm(TINFO,"(case%02d) START", i);
> +	                ret = do_test(&tcase[i]);
> +	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
> +	                result |= ret;
> +        	}
> +		
> +		/*
> +        	 * Check results
> +         	*/
> +        	switch(result) {
> +	        case RESULT_OK:
> +        			tst_resm(TPASS, "ppoll01 call succeeded ");
> +		                break;
> +
> +	        default:
> +                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
> +        		        RPRINTF("NG");
> +				cleanup();
> +				tst_exit();
> +		                break;
> +        	}
> +
> +                }
> +        }	
> +        cleanup();
> +	tst_exit();
> +}
> +
> --- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 12:58:57.000000000 +0530
> +++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 13:06:52.000000000 +0530
> @@ -706,6 +706,8 @@ pipe2_02 pipe2_02
> 
>  poll01 poll01
> 
> +ppoll01 ppoll01
> +
>  prctl01 prctl01
>  prctl02 prctl02
> 


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [LTP] [PATCH 07/13] Add/Port mq_open01 test for mq_open() syscall
  2009-05-27 10:10 ` [LTP] [PATCH 07/13] Add/Port mq_open01 test for mq_open() syscall Manas Kumar Nayak
@ 2009-05-29 12:56   ` Subrata Modak
  0 siblings, 0 replies; 31+ messages in thread
From: Subrata Modak @ 2009-05-29 12:56 UTC (permalink / raw)
  To: Manas Kumar Nayak; +Cc: LTP List

On Wed, 2009-05-27 at 15:40 +0530, Manas Kumar Nayak wrote: 
> Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>

Thanks.

Regards--
Subrata

> To: LTP List <ltp-list@lists.sourceforge.net>
> Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
> Cc: Masatake YAMATO <yamato@redhat.com>
> ---
> 
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_open/Makefile	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_open/Makefile	2009-05-23 12:03:30.000000000 +0530
> @@ -0,0 +1,31 @@
> +#
> +#  Copyright (c) International Business Machines  Corp., 2009
> +#
> +#  This program is free software;  you can redistribute it and/or modify
> +#  it under the terms of the GNU General Public License as published by
> +#  the Free Software Foundation; either version 2 of the License, or
> +#  (at your option) any later version.
> +#
> +#  This program is distributed in the hope that it will be useful,
> +#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
> +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> +#  the GNU General Public License for more details.
> +#
> +#  You should have received a copy of the GNU General Public License
> +#  along with this program;  if not, write to the Free Software
> +#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#
> +
> +CFLAGS += -I../../../../include -Wall -O2
> +LDLIBS += -L../../../../lib -lltp -lrt
> +
> +SRCS    = $(wildcard *.c)
> +TARGETS = $(patsubst %.c,%,$(SRCS))
> +
> +all: $(TARGETS)
> +
> +install:
> +	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
> +
> +clean:
> +	rm -f $(TARGETS)
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_open/mq_open01.c	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_open/mq_open01.c	2009-05-27 13:11:05.000000000 +0530
> @@ -0,0 +1,520 @@
> +/******************************************************************************/
> +/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
> +/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
> +/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
> +/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
> +/*                                                                  	      */
> +/* This program is free software;  you can redistribute it and/or modify      */
> +/* it under the terms of the GNU General Public License as published by       */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> +/*                                                                            */
> +/******************************************************************************/
> +/******************************************************************************/
> +/*                                                                            */
> +/* File:        mq_open01.c                                                   */
> +/*                                                                            */
> +/* Description: This tests the mq_open() syscall                              */
> +/*									      */
> +/* 									      */
> +/*									      */
> +/*									      */
> +/*									      */
> +/*                                                                            */
> +/* Usage:  <for command-line>                                                 */
> +/* mq_open01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                             */
> +/*      where,  -c n : Run n copies concurrently.                             */
> +/*              -e   : Turn on errno logging.                                 */
> +/*              -i n : Execute test n times.                                  */
> +/*              -I x : Execute test for x seconds.                            */
> +/*              -P x : Pause for x seconds between iterations.                */
> +/*              -t   : Turn on syscall timing.                                */
> +/*                                                                            */
> +/* Total Tests: 1                                                             */
> +/*                                                                            */
> +/* Test Name:   mq_open01                                                     */
> +/* History:     Porting from Crackerjack to LTP is done by                    */
> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
> +/******************************************************************************/
> +#include <sys/syscall.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <sys/uio.h>
> +#include <getopt.h>
> +#include <stdlib.h>
> +#include <errno.h>
> +#include <stdio.h>
> +#include <unistd.h>
> +#include <string.h>
> +#include <mqueue.h>
> +#include <limits.h>
> +
> +
> +#include "../utils/include_j_h.h"
> +#include "../utils/common_j_h.c"
> +
> +/* Harness Specific Include Files. */
> +#include "test.h"
> +#include "usctest.h"
> +#include "linux_syscall_numbers.h"
> +
> +/* Extern Global Variables */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> +
> +/* Global Variables */
> +char *TCID = "mq_open01";  /* Test program identifier.*/
> +int  testno;
> +int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
> +
> +/* Extern Global Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    cleanup                                                       */
> +/*                                                                            */
> +/* Description: Performs all one time clean up for this test on successful    */
> +/*              completion,  premature exit or  failure. Closes all temporary */
> +/*              files, removes all temporary directories exits the test with  */
> +/*              appropriate return code by calling tst_exit() function.       */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> +/*              On success - Exits calling tst_exit(). With '0' return code.  */
> +/*                                                                            */
> +/******************************************************************************/
> +extern void cleanup() {
> +        /* Remove tmp dir and all files in it */
> +        TEST_CLEANUP;
> +        tst_rmdir();
> +
> +        /* Exit with appropriate return code. */
> +        tst_exit();
> +}
> +
> +/* Local  Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    setup                                                         */
> +/*                                                                            */
> +/* Description: Performs all one time setup for this test. This function is   */
> +/*              typically used to capture signals, create temporary dirs      */
> +/*              and temporary files that may be used in the course of this    */
> +/*              test.                                                         */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits by calling cleanup().                      */
> +/*              On success - returns 0.                                       */
> +/*                                                                            */
> +/******************************************************************************/
> +void setup() {
> +        /* Capture signals if any */
> +        /* Create temporary directories */
> +        TEST_PAUSE;
> +        tst_tmpdir();
> +}
> +
> +
> +/*
> + * Macros
> + */
> +#define SYSCALL_NAME    "mq_open"
> +
> +#ifndef __NR_mq_getsetattr
> +#  define __NR_mq_getsetattr            282
> +#endif
> +
> +
> +/*
> + * Global variables
> + */
> +static int opt_debug;
> +static char *progname;
> +
> +enum test_type {
> +		NORMAL,
> +		NO_FILE,
> +	        NO_SPACE,
> +};
> +
> +
> +/*
> + * Data Structure
> + */
> +struct test_case {
> +	int ttype;
> +        char *user;
> +        char *qname;
> +        int oflag;
> +        long mq_maxmsg;         // Maximum numebr of messages.
> +        long mq_msgsize;        // Maximum message size.
> +        int ret;
> +        int err;
> +};
> +
> +#define ULIMIT_FNUM     0
> +#define PROC_MAX_QUEUES "/proc/sys/fs/mqueue/queues_max"
> +
> +/* Test cases
> + *
> + *   test status of errors on man page
> + *
> + *   EACCES             v (permission is denied)
> + *   EEXIST             v (named message queue already exists)
> + *   EINTR              --- (interrupted by a signal)
> + *   EINVAL             v (not supported for the given name, or invalid
> + *                         arguments)
> + *   EMFILE             v (process file table overflow)
> + *   ENAMETOOLONG       v (too long name length)
> + *   ENFILE             can't check because it's difficult to create no-fd
> + *   ENOENT             v (O_CREAT is not set and the named message queue
> + *                         does not exist)
> + *   ENOSPC             v (no space for the new message queue)
> + */
> +
> +
> +static struct test_case tcase[] = {
> +#if 1
> +        { // case00
> +                .ttype          = NORMAL,
> +                .qname          = QUEUE_NAME,
> +                .oflag          = O_CREAT,
> +                .mq_maxmsg      = 20,
> +                .mq_msgsize     = 16384,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +#else
> +        { // case00
> +                .ttype          = NORMAL,
> +                .qname          = QUEUE_NAME,
> +                .oflag          = O_CREAT,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case01
> +                .ttype          = NORMAL,
> +                                //  0         1         2         3
> +                                //  0123456789012345678901234567890123456789
> +                .qname          = "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaa",
> +                .oflag          = O_CREAT,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case02
> +                .ttype          = NORMAL,
> +                                //  0         1         2         3
> +                                //  0123456789012345678901234567890123456789
> +                .qname          = "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaa",
> +                .oflag          = O_CREAT,
> +                .ret            = -1,
> +                .err            = ENAMETOOLONG,
> +        },
> +
> +	{ // case03
> +                .ttype          = NORMAL,
> +                .qname          = "",
> +                .oflag          = O_CREAT,
> +                .ret            = -1,
> +                .err            = EINVAL,
> +        },
> +        { // case04
> +                .ttype          = NORMAL,
> +                .user           = "nobody",
> +                .qname          = QUEUE_NAME,
> +                .ret            = -1,
> +                .err            = EACCES,
> +        },
> +        { // case05
> +                .ttype          = NORMAL,
> +                .qname          = QUEUE_NAME,
> +                .oflag          = O_CREAT|O_EXCL,
> +                .ret            = -1,
> +                .err            = EEXIST,
> +        },
> +        { // case06
> +                .ttype          = NO_FILE,
> +                .qname          = QUEUE_NAME,
> +                .oflag          = O_CREAT,
> +                .ret            = -1,
> +                .err            = EMFILE,
> +        },
> +        { // case07
> +                .ttype          = NORMAL,
> +                .qname          = "/notexist",
> +                .oflag          = 0,
> +                .ret            = -1,
> +                .err            = ENOENT,
> +        },
> +
> +	{ // case08
> +                .ttype          = NO_SPACE,
> +                .user           = "nobody",
> +                .qname          = QUEUE_NAME,
> +                .oflag          = O_CREAT,
> +                .ret            = -1,
> +                .err            = ENOSPC,
> +        },
> +#endif
> +};
> +
> +
> +/*
> + * do_test()
> + *
> + *   Input  : TestCase Data
> + *   Return : RESULT_OK(0), RESULT_NG(1)
> + *
> + */
> +
> +static int do_test(struct test_case *tc)
> +{
> +        int sys_ret;
> +        int sys_errno;
> +        int result = RESULT_OK;
> +	int rc, fd1 = -1, fd2 = -1, cmp_ok = 1;
> +        uid_t old_uid = -1;
> +        rlim_t oldlim = -1;
> +        int oldval = -1;
> +        struct mq_attr new, old, *p_attr;
> +	
> +	 /*
> +         * When test ended with SIGTERM etc, mq discriptor is left remains.
> +         * So we delete it first.
> +         */
> +        TEST(mq_unlink(QUEUE_NAME));
> +
> +	
> +	/*
> +         * Execute system call
> +         */
> +
> +	if (tc->ttype != NO_SPACE) {
> +                errno = 0;
> +                TEST(sys_ret = mq_open(QUEUE_NAME, O_CREAT|O_EXCL|O_RDWR, S_IRWXU, NULL));
> +                sys_errno = errno;
> +                if (sys_ret < 0)
> +                        goto TEST_END;
> +                fd1 = sys_ret;
> +        }
> +	if (tc->ttype == NO_FILE) {
> +                TEST(rc = setup_ulimit_fnum(ULIMIT_FNUM, &oldlim));
> +                if (rc < 0) {
> +                        result = 1;
> +                        goto EXIT;
> +                }
> +        }
> +
> +	/*
> +         * Change /proc/sys/fs/mqueue/queues_max
> +         */
> +        if (tc->ttype == NO_SPACE) {
> +                TEST(rc = setup_proc_fs(PROC_MAX_QUEUES, 0, &oldval));
> +                if (rc < 0) {
> +                        result = 1;
> +                        goto EXIT;
> +                }
> +        }
> +
> +	/*
> +         * Change effective user id
> +         */
> +        if (tc->user != NULL) {
> +                TEST(rc = setup_euid(tc->user, &old_uid));
> +                if (rc < 0) {
> +                        result = 1;
> +                        goto EXIT;
> +                }
> +        }
> +
> +	 /*
> +         * Execute system call
> +         */
> +        //tst_resm(TINFO,"PATH_MAX: %d\n", PATH_MAX);
> +        //tst_resm(TINFO,"NAME_MAX: %d", NAME_MAX);
> +        p_attr = NULL;
> +        if (tc->mq_maxmsg || tc->mq_msgsize) {
> +                new.mq_maxmsg = tc->mq_maxmsg;
> +                new.mq_msgsize = tc->mq_msgsize;
> +                p_attr = &new;
> +        }
> +        errno = 0;
> +	if (tc->oflag & O_CREAT)
> +                TEST(sys_ret = mq_open(tc->qname, tc->oflag, S_IRWXU, p_attr));
> +        else
> +                TEST(sys_ret = mq_open(tc->qname, tc->oflag));
> +        sys_errno = errno;
> +        if (sys_ret < 0)
> +                goto TEST_END;
> +        fd2 = sys_ret;
> +
> +        if (p_attr) {
> +                TEST(rc = syscall(__NR_mq_getsetattr, fd2, NULL, &old));
> +                if (TEST_RETURN < 0) {
> +                 	tst_resm(TFAIL, "mq_getsetattr failed - errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        result = 1;
> +                        goto EXIT;
> +                }
> +		if (opt_debug) {
> +                        tst_resm(TINFO,"mq_maxmsg E:%ld,\tR:%ld",new.mq_maxmsg, old.mq_maxmsg);
> +                        tst_resm(TINFO,"mq_msgsize E:%ld,\tR:%ld",new.mq_msgsize, old.mq_msgsize);
> +                }
> +                cmp_ok = old.mq_maxmsg == new.mq_maxmsg &&
> +                         old.mq_msgsize == new.mq_msgsize;
> +        }
> +
> +TEST_END:
> +        /*
> +         * Check results
> +         */
> +        result |= (sys_errno != tc->err) || !cmp_ok;
> +        PRINT_RESULT_CMP(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno,cmp_ok);
> +
> +EXIT:
> +        if (tc->user != NULL && old_uid != -1)
> +                TEST(cleanup_euid(old_uid));
> +
> +        if (tc->ttype == NO_SPACE && oldval != -1)
> +                TEST(cleanup_proc_fs(PROC_MAX_QUEUES, oldval));
> +
> +        if (tc->ttype == NO_FILE && oldlim != -1)
> +                TEST(cleanup_ulimit_fnum(oldlim));
> +	 if (fd1 >= 0)
> +                TEST(close(fd1));
> +        if (fd2 >= 0)
> +                TEST(close(fd2));
> +        if (fd1 >= 0)
> +                TEST(mq_unlink(QUEUE_NAME));
> +        if (fd2 >= 0 && strcmp(tc->qname, QUEUE_NAME) != 0)
> +                TEST(mq_unlink(tc->qname));
> +
> +        return result;
> +}
> +
> +
> +/*
> + * usage()
> + */
> +
> +static void usage(const char *progname)
> +{
> +        tst_resm(TINFO,"usage: %s [options]", progname);
> +        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
> +        tst_resm(TINFO,"options:");
> +        tst_resm(TINFO,"    -d --debug           Show debug messages");
> +        tst_resm(TINFO,"    -h --help            Show this message");
> +        tst_resm(TINFO,"NG");
> +        exit(1);
> +}
> +
> +
> +/*
> + * main()
> + */
> +
> +int main(int ac, char **av) {
> +	int result = RESULT_OK;
> +        int c;
> +        int i;
> +        int lc;                 /* loop counter */
> +        char *msg;              /* message returned from parse_opts */
> +
> +	struct option long_options[] = {
> +                { "debug", no_argument, 0, 'd' },
> +                { "help",  no_argument, 0, 'h' },
> +                { NULL, 0, NULL, 0 }
> +        };
> +
> +	progname = strchr(av[0], '/');
> +        progname = progname ? progname + 1 : av[0];	
> +	
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> +
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
> +			 while(TEST_RETURN != -1) {
> +		                switch (c) {
> +                		case 'd':
> +		                        opt_debug = 1;
> +                		        break;
> +		                default:
> +                		        usage(progname);
> +                        		// NOTREACHED
> +                		}
> +		        }
> +
> +
> +		if (ac != optind) {
> +        	        tst_resm(TINFO,"Options are not match.");
> +                	usage(progname);
> +                	// NOTREACHED
> +	        }
> +
> +		/*
> +		* Execute test
> +         	*/
> +	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
> +        	        int ret;
> +	                tst_resm(TINFO,"(case%02d) START", i);
> +	                ret = do_test(&tcase[i]);
> +	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
> +	                result |= ret;
> +        	}
> +		
> +		/*
> +        	 * Check results
> +         	*/
> +        	switch(result) {
> +	        case RESULT_OK:
> +        			tst_resm(TPASS, "mq_open call succeeded ");
> +		                break;
> +
> +	        default:
> +                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
> +        		        tst_resm(TINFO,"NG");
> +				cleanup();
> +				tst_exit();
> +		                break;
> +        	}
> +
> +                }
> +        }	
> +        cleanup();
> +	tst_exit();
> +}
> +
> --- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 13:08:52.000000000 +0530
> +++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 13:20:31.000000000 +0530
> @@ -586,6 +586,7 @@ mprotect02 mprotect02
>  mprotect03 mprotect03
> 
>  mq_notify01 mq_notify01
> +mq_open01 mq_open01
> 
>  mremap01 mremap01
>  mremap02 mremap02
> 
> ---
> Regards--
> Manas
> 


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [LTP] [PATCH 08/13] Add/Port mq_timedreceive01 test for mq_timedreceive() syscall
  2009-05-27 10:10 ` [LTP] [PATCH 08/13] Add/Port mq_timedreceive01 test for mq_timedreceive() syscall Manas Kumar Nayak
@ 2009-05-29 12:56   ` Subrata Modak
  0 siblings, 0 replies; 31+ messages in thread
From: Subrata Modak @ 2009-05-29 12:56 UTC (permalink / raw)
  To: Manas Kumar Nayak; +Cc: LTP List

On Wed, 2009-05-27 at 15:40 +0530, Manas Kumar Nayak wrote: 
> Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>
> To: LTP List <ltp-list@lists.sourceforge.net>

Thanks.

Regards--
Subrata

> Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
> Cc: Masatake YAMATO <yamato@redhat.com>
> ---
> 
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_timedreceive/Makefile	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_timedreceive/Makefile	2009-05-23 14:30:57.000000000 +0530
> @@ -0,0 +1,31 @@
> +#
> +#  Copyright (c) International Business Machines  Corp., 2009
> +#
> +#  This program is free software;  you can redistribute it and/or modify
> +#  it under the terms of the GNU General Public License as published by
> +#  the Free Software Foundation; either version 2 of the License, or
> +#  (at your option) any later version.
> +#
> +#  This program is distributed in the hope that it will be useful,
> +#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
> +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> +#  the GNU General Public License for more details.
> +#
> +#  You should have received a copy of the GNU General Public License
> +#  along with this program;  if not, write to the Free Software
> +#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#
> +
> +CFLAGS += -I../../../../include -Wall -O2 -D_POSIX_C_SOURCE=$(shell getconf _POSIX_MESSAGE_PASSING)L
> +LDLIBS += -L../../../../lib -lltp -lrt
> +
> +SRCS    = $(wildcard *.c)
> +TARGETS = $(patsubst %.c,%,$(SRCS))
> +
> +all: $(TARGETS)
> +
> +install:
> +	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
> +
> +clean:
> +	rm -f $(TARGETS)
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c	2009-05-27 13:23:51.000000000 +0530
> @@ -0,0 +1,548 @@
> +/******************************************************************************/
> +/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
> +/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
> +/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
> +/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
> +/*                                                                  	      */
> +/* This program is free software;  you can redistribute it and/or modify      */
> +/* it under the terms of the GNU General Public License as published by       */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> +/*                                                                            */
> +/******************************************************************************/
> +/******************************************************************************/
> +/*                                                                            */
> +/* File:        mq_timedreceive01.c                                           */
> +/*                                                                            */
> +/* Description: This tests the mq_timedreceive() syscall                      */
> +/*									      */
> +/* 									      */
> +/*									      */
> +/*									      */
> +/*									      */
> +/*                                                                            */
> +/* Usage:  <for command-line>                                                 */
> +/* mq_timedreceive01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                     */
> +/*      where,  -c n : Run n copies concurrently.                             */
> +/*              -e   : Turn on errno logging.                                 */
> +/*              -i n : Execute test n times.                                  */
> +/*              -I x : Execute test for x seconds.                            */
> +/*              -P x : Pause for x seconds between iterations.                */
> +/*              -t   : Turn on syscall timing.                                */
> +/*                                                                            */
> +/* Total Tests: 1                                                             */
> +/*                                                                            */
> +/* Test Name:   mq_timedreceive01                                             */
> +/* History:     Porting from Crackerjack to LTP is done by                    */
> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
> +/******************************************************************************/
> +#include <sys/syscall.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <sys/wait.h>
> +#include <getopt.h>
> +#include <stdlib.h>
> +#include <errno.h>
> +#include <stdio.h>
> +#include <unistd.h>
> +#include <string.h>
> +#include <mqueue.h>
> +#include <time.h>
> +#include <signal.h>
> +#include <limits.h>
> +
> +
> +#include "../utils/include_j_h.h"
> +#include "../utils/common_j_h.c"
> +
> +/* Harness Specific Include Files. */
> +#include "test.h"
> +#include "usctest.h"
> +#include "linux_syscall_numbers.h"
> +
> +/* Extern Global Variables */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> +
> +/* Global Variables */
> +char *TCID = "mq_timedreceive01";  /* Test program identifier.*/
> +int  testno;
> +int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
> +
> +/* Extern Global Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    cleanup                                                       */
> +/*                                                                            */
> +/* Description: Performs all one time clean up for this test on successful    */
> +/*              completion,  premature exit or  failure. Closes all temporary */
> +/*              files, removes all temporary directories exits the test with  */
> +/*              appropriate return code by calling tst_exit() function.       */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> +/*              On success - Exits calling tst_exit(). With '0' return code.  */
> +/*                                                                            */
> +/******************************************************************************/
> +extern void cleanup() {
> +        /* Remove tmp dir and all files in it */
> +        TEST_CLEANUP;
> +        tst_rmdir();
> +
> +        /* Exit with appropriate return code. */
> +        tst_exit();
> +}
> +
> +/* Local  Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    setup                                                         */
> +/*                                                                            */
> +/* Description: Performs all one time setup for this test. This function is   */
> +/*              typically used to capture signals, create temporary dirs      */
> +/*              and temporary files that may be used in the course of this    */
> +/*              test.                                                         */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits by calling cleanup().                      */
> +/*              On success - returns 0.                                       */
> +/*                                                                            */
> +/******************************************************************************/
> +void setup() {
> +        /* Capture signals if any */
> +        /* Create temporary directories */
> +        TEST_PAUSE;
> +        tst_tmpdir();
> +}
> +
> +
> +/*
> + * Macros
> + */
> +#define SYSCALL_NAME    "mq_timedreceive"
> +
> +
> +/*
> + * Global variables
> + */
> +static int opt_debug;
> +static char *progname;
> +
> +enum test_type {
> +	NORMAL,
> +        FD_NONE,
> +        FD_NOT_EXIST,
> +        FD_FILE,
> +        INVALID_MSG_LEN,
> +        EMPTY_QUEUE,
> +        SEND_SIGINT,
> +};
> +
> +
> +/*
> + * Data Structure
> + */
> +struct test_case {
> +	int ttype;
> +        int non_block;
> +        int len;
> +        unsigned prio;
> +        time_t sec;
> +        long nsec;
> +        int ret;
> +        int err;
> +};
> +
> +#define MAX_MSG         10
> +#define MAX_MSGSIZE     8192
> +
> +/* Test cases
> + *
> + *   test status of errors on man page
> + *
> + *   EAGAIN             v (would block)
> + *   EBADF              v (not a valid descriptor)
> + *   EINTR              v (interrupted by a signal)
> + *   EINVAL             v (invalid timeout value)
> + *   ETIMEDOUT          v (not block and timeout occured)
> + *   EMSGSIZE           v ('msg_len' is less than the message size of the queue)
> + *   EBADMSG            can't check because this error never occur
> + */
> +static struct test_case tcase[] = {
> +        { // case00
> +                .ttype          = NORMAL,
> +                .len            = 0,    // also success when size equals zero
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +	{ // case01
> +                .ttype          = NORMAL,
> +                .len            = 1,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case02
> +                .ttype          = NORMAL,
> +                .len            = MAX_MSGSIZE,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case03
> +                .ttype          = NORMAL,
> +                .len            = 1,
> +                .prio           = 32767, // max priority
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +	{ // case04
> +                .ttype          = INVALID_MSG_LEN,
> +                .len            = 0,
> +                .ret            = -1,
> +                .err            = EMSGSIZE,
> +        },
> +        { // case05
> +                .ttype          = FD_NONE,
> +                .len            = 0,
> +                .ret            = -1,
> +                .err            = EBADF,
> +        },
> +        { // case06
> +                .ttype          = FD_NOT_EXIST,
> +                .len            = 0,
> +                .ret            = -1,
> +                .err            = EBADF,
> +        },
> +        { // case07
> +                .ttype          = FD_FILE,
> +                .len            = 0,
> +                .ret            = -1,
> +                .err            = EBADF,
> +        },
> +        { // case08
> +                .ttype          = EMPTY_QUEUE,
> +                .non_block      = 1,
> +                .len            = 16,
> +                .ret            = -1,
> +                .err            = EAGAIN,
> +        },
> +        { // case09
> +                .ttype          = EMPTY_QUEUE,
> +                .len            = 16,
> +                .sec            = -1,
> +                .nsec           = 0,
> +                .ret            = -1,
> +                .err            = EINVAL,
> +        },
> +	{ // case10
> +                .ttype          = EMPTY_QUEUE,
> +                .len            = 16,
> +                .sec            = 0,
> +                .nsec           = -1,
> +                .ret            = -1,
> +                .err            = EINVAL,
> +        },
> +        { // case11
> +                .ttype          = EMPTY_QUEUE,
> +                .len            = 16,
> +                .sec            = 0,
> +                .nsec           = 1000000000,
> +                .ret            = -1,
> +                .err            = EINVAL,
> +        },
> +        { // case12
> +                .ttype          = EMPTY_QUEUE,
> +                .len            = 16,
> +                .sec            = 0,
> +                .nsec           = 999999999,
> +                .ret            = -1,
> +                .err            = ETIMEDOUT,
> +        },
> +        { // case13
> +                .ttype          = SEND_SIGINT,
> +                .len            = 16,
> +                .ret            = -1,
> +                .err            = EINTR,
> +        },
> +};
> +
> +
> +
> +
> +#define MEM_LENGTH              (4 * 1024 * 1024)
> +/*
> + * do_test()
> + *
> + *   Input  : TestCase Data
> + *   Return : RESULT_OK(0), RESULT_NG(1)
> + *
> + */
> +
> +static int do_test(struct test_case *tc)
> +{
> +        int sys_ret;
> +        int sys_errno;
> +        int result = RESULT_OK;
> +	int oflag;
> +        int i, rc, cmp_ok = 1, fd = -1;
> +        char smsg[MAX_MSGSIZE], rmsg[MAX_MSGSIZE];
> +        struct timespec ts, *p_ts;
> +        pid_t pid = 0;
> +        unsigned prio;
> +        size_t msg_len;
> +
> +	/*
> +         * When test ended with SIGTERM etc, mq discriptor is left remains.
> +         * So we delete it first.
> +         */
> +        TEST(mq_unlink(QUEUE_NAME));
> +
> +switch (tc->ttype) {
> +        case FD_NOT_EXIST:
> +                fd = INT_MAX - 1;
> +                /* fallthrough */
> +        case FD_NONE:
> +                break;
> +        case FD_FILE:
> +                TEST(fd = open("/", O_RDONLY));
> +                if (TEST_RETURN < 0) {
> +                 	tst_resm(TFAIL, "can't open \"/\". - errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        result = 1;
> +                        goto EXIT;
> +                }
> +                break;
> +        default:
> +                /*
> +                 * Open message queue
> +                 */
> +                oflag = O_CREAT|O_EXCL|O_RDWR;
> +                if (tc->non_block)
> +                        oflag |= O_NONBLOCK;
> +
> +                TEST(fd = mq_open(QUEUE_NAME, oflag, S_IRWXU, NULL));
> +                if (TEST_RETURN < 0) {
> +                 	tst_resm(TFAIL, "mq_open failed - errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        result = 1;
> +                        goto EXIT;
> +                }
> +
> +		 if (tc->ttype == SEND_SIGINT) {
> +                        TEST(pid = create_sig_proc(200000, SIGINT));
> +                        if (TEST_RETURN < 0) {
> +                                result = 1;
> +                                goto EXIT;
> +                        }
> +                }
> +                break;
> +           }
> +
> +	/*
> +         * Prepare send message
> +         */
> +        for (i = 0; i < tc->len; i++)
> +                smsg[i] = i;
> +
> +        /*
> +         * Send message
> +         */
> +        switch (tc->ttype) {
> +        case EMPTY_QUEUE:
> +        case SEND_SIGINT:
> +        case FD_NONE:
> +        case FD_NOT_EXIST:
> +        case FD_FILE:
> +                break;
> +        default:
> +		TEST(rc = mq_timedsend(fd, smsg, tc->len, tc->prio, NULL));
> +                if (TEST_RETURN < 0) {
> +                 	tst_resm(TFAIL, "mq_timedsend failed - errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                        result = 1;
> +                        goto EXIT;
> +                }
> +                break;
> +        }
> +
> +        /*
> +         * Set the message length and timeout value
> +         */
> +        msg_len = MAX_MSGSIZE;
> +        if (tc->ttype == INVALID_MSG_LEN)
> +                msg_len -= 1;
> +        ts.tv_sec = tc->sec;
> +        ts.tv_nsec = tc->nsec;
> +        p_ts = &ts;
> +        if (tc->sec == 0 && tc->nsec == 0)
> +                p_ts = NULL;
> +
> +	/*
> +         * Execute system call
> +         */
> +        errno = 0;
> +        TEST(sys_ret = mq_timedreceive(fd, rmsg, msg_len, &prio, p_ts));
> +        sys_errno = errno;
> +        if (sys_ret < 0)
> +                goto TEST_END;
> + 
> +	 /*
> +         * Compare received message
> +         */
> +        if (sys_ret != tc->len || tc->prio != prio)
> +                cmp_ok = 0;
> +        else {
> +                for (i = 0; i < tc->len; i++)
> +                        if (rmsg[i] != smsg[i]) {
> +                                cmp_ok = 0;
> +                                break;
> +                        }
> +        }
> +
> +
> +	TEST_END:
> +        /*
> +         * Check results
> +         */
> +        result |= (sys_errno != tc->err) || !cmp_ok;
> +        PRINT_RESULT_CMP(0, tc->ret == 0 ? tc->len : tc->ret, tc->err,sys_ret, sys_errno, cmp_ok);
> +
> +EXIT:
> +        if (fd >= 0) {
> +                TEST(close(fd));
> +                TEST(mq_unlink(QUEUE_NAME));
> +        }
> +        if (pid > 0) {
> +                int st;
> +                TEST(kill(pid, SIGTERM));
> +                TEST(wait(&st));
> +        }
> +        return result;
> +}
> +
> +/*
> + * sighandler()
> + */
> +void sighandler(int sig)
> +{
> +        if (sig == SIGINT)
> +                return;
> +        // NOTREACHED
> +        return;
> +}
> +
> +
> +
> +/*
> + * usage()
> + */
> +
> +static void usage(const char *progname)
> +{
> +        tst_resm(TINFO,"usage: %s [options]", progname);
> +        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
> +        tst_resm(TINFO,"options:");
> +        tst_resm(TINFO,"    -d --debug           Show debug messages");
> +        tst_resm(TINFO,"    -h --help            Show this message");
> +        tst_resm(TINFO,"NG");
> +        exit(1);
> +}
> +
> +
> +/*
> + * main()
> + */
> +
> +
> +
> +int main(int ac, char **av) {
> +	int result = RESULT_OK;
> +        int c;
> +        int i;
> +        int lc;                 /* loop counter */
> +        char *msg;              /* message returned from parse_opts */
> +
> +	struct option long_options[] = {
> +                { "debug", no_argument, 0, 'd' },
> +                { "help",  no_argument, 0, 'h' },
> +                { NULL, 0, NULL, 0 }
> +        };
> +
> +	progname = strchr(av[0], '/');
> +        progname = progname ? progname + 1 : av[0];	
> +	
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> +
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
> +			 while(TEST_RETURN != -1) {
> +		                switch (c) {
> +                		case 'd':
> +		                        opt_debug = 1;
> +                		        break;
> +		                default:
> +                		        usage(progname);
> +                        		// NOTREACHED
> +                		}
> +		        }
> +
> +
> +		if (ac != optind) {
> +        	        tst_resm(TINFO,"Options are not match.");
> +                	usage(progname);
> +                	// NOTREACHED
> +	        }
> +
> +		/*
> +		* Execute test
> +         	*/
> +	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
> +        	        int ret;
> +	                tst_resm(TINFO,"(case%02d) START", i);
> +	                ret = do_test(&tcase[i]);
> +	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
> +	                result |= ret;
> +        	}
> +		
> +		/*
> +        	 * Check results
> +         	*/
> +        	switch(result) {
> +	        case RESULT_OK:
> +        			tst_resm(TPASS, "mq_timedreceive call succeeded");
> +		                break;
> +
> +	        default:
> +                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
> +        		        tst_resm(TINFO,"NG");
> +				cleanup();
> +				tst_exit();
> +		                break;
> +        	}
> +
> +                }
> +        }	
> +        cleanup();
> +	tst_exit();
> +}
> +
> --- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 13:28:26.000000000 +0530
> +++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 13:27:56.000000000 +0530
> @@ -587,6 +587,7 @@ mprotect03 mprotect03
> 
>  mq_notify01 mq_notify01
>  mq_open01 mq_open01
> +mq_timedreceive01 mq_timedreceive01
> 
>  mremap01 mremap01
>  mremap02 mremap02
> 
> ---
> Regards--
> Manas
> 


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [LTP] [PATCH 09/13] Add/Port utimes01 test for utimes() syscall
  2009-05-27 10:11 ` [LTP] [PATCH 09/13] Add/Port utimes01 test for utimes() syscall Manas Kumar Nayak
@ 2009-05-29 12:56   ` Subrata Modak
  0 siblings, 0 replies; 31+ messages in thread
From: Subrata Modak @ 2009-05-29 12:56 UTC (permalink / raw)
  To: Manas Kumar Nayak; +Cc: LTP List

On Wed, 2009-05-27 at 15:41 +0530, Manas Kumar Nayak wrote: 
> Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>

Thanks.

Regards--
Subrata

> To: LTP List <ltp-list@lists.sourceforge.net>
> Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
> Cc: Masatake YAMATO <yamato@redhat.com>
> ---
> 
> --- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 13:31:15.000000000 +0530
> +++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 13:39:18.000000000 +0530
> @@ -1227,6 +1227,8 @@ utime04 utime04
>  utime05 utime05
>  utime06 utime06
> 
> +utimes01 utimes01
> +
>  # Introduced from Kernel 2.6.22 onwards
>  utimensat01 utimensat_tests.sh
> 
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/utimes/Makefile	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/utimes/Makefile	2009-05-23 14:53:58.000000000 +0530
> @@ -0,0 +1,31 @@
> +#
> +#  Copyright (c) International Business Machines  Corp., 2009
> +#
> +#  This program is free software;  you can redistribute it and/or modify
> +#  it under the terms of the GNU General Public License as published by
> +#  the Free Software Foundation; either version 2 of the License, or
> +#  (at your option) any later version.
> +#
> +#  This program is distributed in the hope that it will be useful,
> +#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
> +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> +#  the GNU General Public License for more details.
> +#
> +#  You should have received a copy of the GNU General Public License
> +#  along with this program;  if not, write to the Free Software
> +#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#
> +
> +CFLAGS += -I../../../../include -Wall -O2
> +LDLIBS += -L../../../../lib -lltp 
> +
> +SRCS    = $(wildcard *.c)
> +TARGETS = $(patsubst %.c,%,$(SRCS))
> +
> +all: $(TARGETS)
> +
> +install:
> +	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
> +
> +clean:
> +	rm -f $(TARGETS)
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/utimes/utimes01.c	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/utimes/utimes01.c	2009-05-27 13:33:45.000000000 +0530
> @@ -0,0 +1,407 @@
> +/******************************************************************************/
> +/* Copyright (c) Crackerjack Project., 2007 ,Hitachi, Ltd                     */
> +/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
> +/*                                                                  	      */
> +/* This program is free software;  you can redistribute it and/or modify      */
> +/* it under the terms of the GNU General Public License as published by       */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> +/*                                                                            */
> +/******************************************************************************/
> +/******************************************************************************/
> +/*                                                                            */
> +/* File:        utimes01.c                                                    */
> +/*                                                                            */
> +/* Description: This tests the utimes() syscall                               */
> +/*									      */
> +/* 									      */
> +/*									      */
> +/*									      */
> +/*									      */
> +/*                                                                            */
> +/* Usage:  <for command-line>                                                 */
> +/* utimes01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                              */
> +/*      where,  -c n : Run n copies concurrently.                             */
> +/*              -e   : Turn on errno logging.                                 */
> +/*              -i n : Execute test n times.                                  */
> +/*              -I x : Execute test for x seconds.                            */
> +/*              -P x : Pause for x seconds between iterations.                */
> +/*              -t   : Turn on syscall timing.                                */
> +/*                                                                            */
> +/* Total Tests: 1                                                             */
> +/*                                                                            */
> +/* Test Name:   utimes01                                                      */
> +/* History:     Porting from Crackerjack to LTP is done by                    */
> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
> +/******************************************************************************/
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <sys/time.h>
> +#include <dirent.h>
> +#include <unistd.h>
> +#include <getopt.h>
> +#include <string.h>
> +#include <stdlib.h>
> +#include <errno.h>
> +#include <stdio.h>
> +#include <libgen.h>
> +
> +
> +#include "../utils/include_j_h.h"
> +#include "../utils/common_j_h.c"
> +
> +
> +/* Harness Specific Include Files. */
> +#include "test.h"
> +#include "usctest.h"
> +#include "linux_syscall_numbers.h"
> +
> +/* Extern Global Variables */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> +
> +/* Global Variables */
> +char *TCID = "utimes01";  /* Test program identifier.*/
> +int  testno;
> +int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
> +
> +/* Extern Global Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    cleanup                                                       */
> +/*                                                                            */
> +/* Description: Performs all one time clean up for this test on successful    */
> +/*              completion,  premature exit or  failure. Closes all temporary */
> +/*              files, removes all temporary directories exits the test with  */
> +/*              appropriate return code by calling tst_exit() function.       */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> +/*              On success - Exits calling tst_exit(). With '0' return code.  */
> +/*                                                                            */
> +/******************************************************************************/
> +extern void cleanup() {
> +        /* Remove tmp dir and all files in it */
> +        TEST_CLEANUP;
> +        tst_rmdir();
> +
> +        /* Exit with appropriate return code. */
> +        tst_exit();
> +}
> +
> +/* Local  Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    setup                                                         */
> +/*                                                                            */
> +/* Description: Performs all one time setup for this test. This function is   */
> +/*              typically used to capture signals, create temporary dirs      */
> +/*              and temporary files that may be used in the course of this    */
> +/*              test.                                                         */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits by calling cleanup().                      */
> +/*              On success - returns 0.                                       */
> +/*                                                                            */
> +/******************************************************************************/
> +void setup() {
> +        /* Capture signals if any */
> +        /* Create temporary directories */
> +        TEST_PAUSE;
> +        tst_tmpdir();
> +}
> +
> +
> +/*
> + * Macros
> + */
> +#define SYSCALL_NAME    "utimes"
> +
> +
> +/*
> + * Global variables
> + */
> +static int opt_debug;
> +static char *progname;
> +static char *progdir;
> +
> +enum test_type {
> +		NORMAL,
> +		FILE_NOT_EXIST,
> +	        NO_FNAME,
> +};
> +
> +
> +/*
> + * Data Structure
> + */
> +struct test_case {
> +	int ttype;
> +        long a_sec;
> +        long m_sec;
> +        char *user;
> +        int ret;
> +        int err;
> +
> +};
> +
> +
> +/* Test cases
> + *
> + *   test status of errors on man page
> + *
> + *   EACCES             v (permission denied)
> + *   ENOENT             v (file does not exist)
> + *
> + *   test status of errors on man page
> + *
> + *   EFAULT             v (points to not process address space)
> + */
> +
> +static struct test_case tcase[] = {
> +	{ // case00
> +                .ttype          = NORMAL,
> +                .a_sec          = 0,
> +                .m_sec          = 1000,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case01
> +                .ttype          = NORMAL,
> +                .a_sec          = 1000,
> +                .m_sec          = 0,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case02
> +                .ttype          = NORMAL,
> +                .a_sec          = 1000,
> +                .m_sec          = 2000,
> +                .user           = "nobody",
> +                .ret            = -1,
> +                .err            = EACCES, // RHEL4U1 + 2.6.18 returns EPERM
> +        },
> +        { // case03
> +                .ttype          = FILE_NOT_EXIST,
> +                .a_sec          = 1000,
> +                .m_sec          = 2000,
> +                .ret            = -1,
> +                .err            = ENOENT,
> +        },
> +
> +	{ // case04
> +                .ttype          = NO_FNAME,
> +                .a_sec          = 1000,
> +                .m_sec          = 2000,
> +                .ret            = -1,
> +                .err            = EFAULT,
> +        },
> +};
> +
> +/*
> + * do_test()
> + *
> + *   Input  : TestCase Data
> + *   Return : RESULT_OK(0), RESULT_NG(1)
> + *
> + */
> +
> +static int do_test(struct test_case *tc)
> +{
> +        int sys_ret;
> +        int sys_errno;
> +        int result = RESULT_OK;
> +	struct timeval tv[2];
> +        char fpath[PATH_MAX], c = '\0';
> +        int rc, len, cmp_ok = 1;
> +        struct stat st;
> +        uid_t old_uid;
> +
> +        TEST(rc = setup_file(progdir, "test.file", fpath));
> +        if (rc < 0)
> +                return 1;
> +
> +	/*
> +         * Change effective user id
> +         */
> +        if (tc->user != NULL) {
> +                TEST(rc = setup_euid(tc->user, &old_uid));
> +                if (rc < 0)
> +                        goto EXIT2;
> +        }
> +
> +        /*
> +         * Execute system call
> +         */
> +        tv[0].tv_sec = tc->a_sec;
> +        tv[1].tv_sec = tc->m_sec;
> +        TEST(len = strlen(fpath));
> +        if (tc->ttype == FILE_NOT_EXIST) {
> +                c = fpath[len - 1];
> +                fpath[len - 1] = '\0';
> +        }
> +        errno = 0;
> +        if (tc->ttype == NO_FNAME)
> +                TEST(sys_ret = utimes(NULL, tv));
> +        else
> +                TEST(sys_ret = utimes(fpath, tv));
> +        sys_errno = errno;
> +        if (tc->ttype == FILE_NOT_EXIST)
> +                fpath[len - 1] = c;
> +        if (sys_ret < 0)
> +                goto TEST_END;
> +
> +	/*
> +         * Check test file's time stamp
> +         */
> +        rc = stat(fpath, &st);
> +        if (rc < 0) {
> +                EPRINTF("stat failed.\n");
> +                result = 1;
> +                goto EXIT1;
> +        }
> +        tst_resm(TINFO,"E:%ld,%ld <=> R:%ld,%ld",tv[0].tv_sec, tv[1].tv_sec, st.st_atime, st.st_mtime);
> +        cmp_ok = st.st_atime == tv[0].tv_sec && st.st_mtime == tv[1].tv_sec;
> +
> +        /*
> +         * Check results
> +         */
> +TEST_END:
> +        result |= (sys_errno != tc->err) || !cmp_ok;
> +        PRINT_RESULT_CMP(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno,cmp_ok);
> +
> +        /*
> +         * Restore effective user id
> +         */
> +EXIT1:
> +        if (tc->user != NULL) {
> +                TEST(rc = cleanup_euid(old_uid));
> +                if (rc < 0)
> +                        return 1;
> +        }
> +EXIT2:
> +        TEST(cleanup_file(fpath));
> +
> +        return result;
> +}
> +
> +/*
> + * usage()
> + */
> +
> +static void usage(const char *progname)
> +{
> +        tst_resm(TINFO,"usage: %s [options]", progname);
> +        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
> +        tst_resm(TINFO,"options:");
> +        tst_resm(TINFO,"    -d --debug           Show debug messages");
> +        tst_resm(TINFO,"    -h --help            Show this message");
> +        tst_resm(TINFO,"NG");
> +        exit(1);
> +}
> +
> +
> +/*
> + * main()
> + */
> +
> +
> +
> +int main(int ac, char **av) {
> +	int result = RESULT_OK;
> +        int c;
> +        int i;
> +        int lc;                 /* loop counter */
> +        char *msg;              /* message returned from parse_opts */
> +
> +	struct option long_options[] = {
> +                { "debug", no_argument, 0, 'd' },
> +                { "help",  no_argument, 0, 'h' },
> +                { NULL, 0, NULL, 0 }
> +        };
> +
> +	progname = strchr(av[0], '/');
> +        progname = progname ? progname + 1 : av[0];	
> +	
> +	progdir = strdup(av[0]);
> +        progdir = dirname(progdir);
> +	
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> +
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
> +			 while(TEST_RETURN != -1) {
> +		                switch (c) {
> +                		case 'd':
> +		                        opt_debug = 1;
> +                		        break;
> +		                default:
> +                		        usage(progname);
> +                        		// NOTREACHED
> +                		}
> +		        }
> +
> +
> +		if (ac != optind) {
> +        	        tst_resm(TINFO,"Options are not match.");
> +                	usage(progname);
> +                	// NOTREACHED
> +	        }
> +
> +		/*
> +		* Execute test
> +         	*/
> +	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
> +        	        int ret;
> +	                tst_resm(TINFO,"(case%02d) START", i);
> +	                ret = do_test(&tcase[i]);
> +	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
> +	                result |= ret;
> +        	}
> +		
> +		/*
> +        	 * Check results
> +         	*/
> +        	switch(result) {
> +	        case RESULT_OK:
> +        			tst_resm(TPASS, "utimes call succeeded ");
> +		                break;
> +
> +	        default:
> +                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
> +        		        tst_resm(TINFO,"NG");
> +				cleanup();
> +				tst_exit();
> +		                break;
> +        	}
> +
> +                }
> +        }	
> +        cleanup();
> +	tst_exit();
> +}
> +
> 
> ---
> Regards--
> Manas
> 


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [LTP] [PATCH 10/13] Add/Port mq_unlink01 test for mq_unlink() syscall
  2009-05-27 10:11 ` [LTP] [PATCH 10/13] Add/Port mq_unlink01 test for mq_unlink() syscall Manas Kumar Nayak
@ 2009-05-29 12:56   ` Subrata Modak
  0 siblings, 0 replies; 31+ messages in thread
From: Subrata Modak @ 2009-05-29 12:56 UTC (permalink / raw)
  To: Manas Kumar Nayak; +Cc: LTP List

On Wed, 2009-05-27 at 15:41 +0530, Manas Kumar Nayak wrote: 
> Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>

Thanks.

Regards--
Subrata

> To: LTP List <ltp-list@lists.sourceforge.net>
> Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
> Cc: Masatake YAMATO <yamato@redhat.com>
> ---
> 
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_unlink/Makefile	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_unlink/Makefile	2009-05-23 14:56:20.000000000 +0530
> @@ -0,0 +1,31 @@
> +#
> +#  Copyright (c) International Business Machines  Corp., 2009
> +#
> +#  This program is free software;  you can redistribute it and/or modify
> +#  it under the terms of the GNU General Public License as published by
> +#  the Free Software Foundation; either version 2 of the License, or
> +#  (at your option) any later version.
> +#
> +#  This program is distributed in the hope that it will be useful,
> +#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
> +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> +#  the GNU General Public License for more details.
> +#
> +#  You should have received a copy of the GNU General Public License
> +#  along with this program;  if not, write to the Free Software
> +#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#
> +
> +CFLAGS += -I../../../../include -Wall -O2
> +LDLIBS += -L../../../../lib -lltp -lrt
> +
> +SRCS    = $(wildcard *.c)
> +TARGETS = $(patsubst %.c,%,$(SRCS))
> +
> +all: $(TARGETS)
> +
> +install:
> +	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
> +
> +clean:
> +	rm -f $(TARGETS)
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_unlink/mq_unlink01.c	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_unlink/mq_unlink01.c	2009-05-27 13:51:14.000000000 +0530
> @@ -0,0 +1,392 @@
> +/******************************************************************************/
> +/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
> +/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
> +/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
> +/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
> +/*                                                                  	      */
> +/* This program is free software;  you can redistribute it and/or modify      */
> +/* it under the terms of the GNU General Public License as published by       */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> +/*                                                                            */
> +/******************************************************************************/
> +/******************************************************************************/
> +/*                                                                            */
> +/* File:        mq_ulink01.c                                                  */
> +/*                                                                            */
> +/* Description: This tests the mq_ulink() syscall                             */
> +/*									      */
> +/* 									      */
> +/*									      */
> +/*									      */
> +/*									      */
> +/*                                                                            */
> +/* Usage:  <for command-line>                                                 */
> +/* mq_ulink01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                            */
> +/*      where,  -c n : Run n copies concurrently.                             */
> +/*              -e   : Turn on errno logging.                                 */
> +/*              -i n : Execute test n times.                                  */
> +/*              -I x : Execute test for x seconds.                            */
> +/*              -P x : Pause for x seconds between iterations.                */
> +/*              -t   : Turn on syscall timing.                                */
> +/*                                                                            */
> +/* Total Tests: 1                                                             */
> +/*                                                                            */
> +/* Test Name:   mq_ulink01                                             */
> +/* History:     Porting from Crackerjack to LTP is done by                    */
> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
> +/******************************************************************************/
> +
> +#include <sys/syscall.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <sys/uio.h>
> +#include <getopt.h>
> +#include <stdlib.h>
> +#include <errno.h>
> +#include <stdio.h>
> +#include <unistd.h>
> +#include <string.h>
> +#include <mqueue.h>
> +#include <limits.h>
> +
> +
> +#include "../utils/include_j_h.h"
> +#include "../utils/common_j_h.c"
> +
> +/* Harness Specific Include Files. */
> +#include "test.h"
> +#include "usctest.h"
> +#include "linux_syscall_numbers.h"
> +
> +/* Extern Global Variables */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> +
> +/* Global Variables */
> +char *TCID = "mq_ulink01";  /* Test program identifier.*/
> +int  testno;
> +int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
> +
> +/* Extern Global Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    cleanup                                                       */
> +/*                                                                            */
> +/* Description: Performs all one time clean up for this test on successful    */
> +/*              completion,  premature exit or  failure. Closes all temporary */
> +/*              files, removes all temporary directories exits the test with  */
> +/*              appropriate return code by calling tst_exit() function.       */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> +/*              On success - Exits calling tst_exit(). With '0' return code.  */
> +/*                                                                            */
> +/******************************************************************************/
> +extern void cleanup() {
> +        /* Remove tmp dir and all files in it */
> +        TEST_CLEANUP;
> +        tst_rmdir();
> +
> +        /* Exit with appropriate return code. */
> +        tst_exit();
> +}
> +
> +/* Local  Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    setup                                                         */
> +/*                                                                            */
> +/* Description: Performs all one time setup for this test. This function is   */
> +/*              typically used to capture signals, create temporary dirs      */
> +/*              and temporary files that may be used in the course of this    */
> +/*              test.                                                         */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits by calling cleanup().                      */
> +/*              On success - returns 0.                                       */
> +/*                                                                            */
> +/******************************************************************************/
> +void setup() {
> +        /* Capture signals if any */
> +        /* Create temporary directories */
> +        TEST_PAUSE;
> +        tst_tmpdir();
> +}
> +
> +
> +/*
> + * Macros
> + */
> +#define SYSCALL_NAME    "mq_ulink"
> +
> +
> +/*
> + * Global variables
> + */
> +static int opt_debug;
> +static char *progname;
> +
> +enum test_type {
> +		NORMAL,
> +};
> +
> +
> +/*
> + * Data Structure
> + */
> +struct test_case {
> +	char *user;
> +        char *qname;
> +        int ttype;
> +        int ret;
> +        int err;
> +};
> +
> +
> +/* Test cases
> +*
> +*   test status of errors on man page
> +*
> +*   EACCES             v (permission is denied)
> +*   ENAMETOOLONG       v (too long name length)
> +*   ENOENT             v (named message queue does not exist)
> +*/
> +
> +static struct test_case tcase[] = {
> +	{ // case00
> +                .ttype          = NORMAL,
> +                .qname          = QUEUE_NAME,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case01
> +                .ttype          = NORMAL,
> +                .user           = "nobody",
> +                .qname          = QUEUE_NAME,
> +                .ret            = -1,
> +                .err            = EACCES,
> +        },
> +        { // case02
> +                .ttype          = NORMAL,
> +                                //  0         1         2         3
> +                                //  0123456789012345678901234567890123456789
> +                .qname          = "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaa",
> +                .ret            = -1,
> +                .err            = ENOENT,
> +        },
> +	{ // case03
> +                .ttype          = NORMAL,
> +                                //  0         1         2         3
> +                                //  0123456789012345678901234567890123456789
> +                .qname          = "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
> +                                   "aaaaaaaaaaaaaaaa",
> +                .ret            = -1,
> +                .err            = ENAMETOOLONG,
> +        },
> +};
> +
> +/*
> + * do_test()
> + *
> + *   Input  : TestCase Data
> + *   Return : RESULT_OK(0), RESULT_NG(1)
> + *
> + */
> +
> +static int do_test(struct test_case *tc)
> +{
> +        int sys_ret;
> +        int sys_errno;
> +        int result = RESULT_OK;
> +	int rc, fd1 = -1, fd2 = -1;
> +        uid_t old_uid = -1;
> +
> +        /*
> +         * When test ended with SIGTERM etc, mq discriptor is left remains.
> +         * So we delete it first.
> +         */
> +        TEST(mq_unlink(QUEUE_NAME));
> +
> +        /*
> +         * Open message queue
> +         */
> +        TEST(rc = mq_open(QUEUE_NAME, O_CREAT|O_EXCL|O_RDWR, S_IRWXU, NULL));
> +	if (TEST_RETURN < 0) {
> +                tst_resm(TFAIL, "mq_open failed - errno = %d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +                result = 1;
> +                goto EXIT;
> +        }
> +        fd1 = rc;
> +
> +        /*
> +         * Change effective user id
> +         */
> +        if (tc->user != NULL) {
> +                TEST(rc = setup_euid(tc->user, &old_uid));
> +                if (TEST_RETURN < 0) {
> +                        result = 1;
> +                        goto EXIT;
> +                }
> +        }
> +
> +/*
> +         * Execute system call
> +         */
> +        //tst_resm(TINFO,"PATH_MAX: %d\n", PATH_MAX);
> +        //tst_resm(TINFO,"NAME_MAX: %d\n", NAME_MAX);
> +        errno = 0;
> +        TEST(sys_ret = mq_unlink(tc->qname));
> +        sys_errno = errno;
> +        if (sys_ret >= 0)
> +                fd2 = sys_ret;
> +
> +        /*
> +         * Check results
> +         */
> +        result |= (sys_errno != tc->err);
> +        PRINT_RESULT(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno);
> +
> +EXIT:
> +        if (tc->user != NULL && old_uid != -1)
> +                cleanup_euid(old_uid);
> +
> +        if (fd1 >= 0)
> +                close(fd1);
> +        if (fd2 >= 0)
> +                close(fd2);
> +        if (fd1 >= 0)
> +                mq_unlink(QUEUE_NAME);
> +
> +        return result;
> +}
> +
> +
> +/*
> + * usage()
> + */
> +
> +static void usage(const char *progname)
> +{
> +        tst_resm(TINFO,"usage: %s [options]", progname);
> +        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
> +        tst_resm(TINFO,"options:");
> +        tst_resm(TINFO,"    -d --debug           Show debug messages");
> +        tst_resm(TINFO,"    -h --help            Show this message");
> +        tst_resm(TINFO,"NG\n");
> +        exit(1);
> +}
> +
> +
> +/*
> + * main()
> + */
> +
> +
> +
> +int main(int ac, char **av) {
> +	int result = RESULT_OK;
> +        int c;
> +        int i;
> +        int lc;                 /* loop counter */
> +        char *msg;              /* message returned from parse_opts */
> +
> +	struct option long_options[] = {
> +                { "debug", no_argument, 0, 'd' },
> +                { "help",  no_argument, 0, 'h' },
> +                { NULL, 0, NULL, 0 }
> +        };
> +
> +	progname = strchr(av[0], '/');
> +        progname = progname ? progname + 1 : av[0];	
> +	
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> +
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
> +			 while(TEST_RETURN != -1) {
> +		                switch (c) {
> +                		case 'd':
> +		                        opt_debug = 1;
> +                		        break;
> +		                default:
> +                		        usage(progname);
> +                        		// NOTREACHED
> +                		}
> +		        }
> +
> +
> +		if (ac != optind) {
> +        	        tst_resm(TINFO,"Options are not match.");
> +                	usage(progname);
> +                	// NOTREACHED
> +	        }
> +
> +		/*
> +		* Execute test
> +         	*/
> +	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
> +        	        int ret;
> +	                tst_resm(TINFO,"(case%02d) START", i);
> +	                ret = do_test(&tcase[i]);
> +	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
> +	                result |= ret;
> +        	}
> +		
> +		/*
> +        	 * Check results
> +         	*/
> +        	switch(result) {
> +	        case RESULT_OK:
> +        			tst_resm(TPASS, "mq_ulink call succeeded");
> +		                break;
> +
> +	        default:
> +                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
> +        		        RPRINTF("NG\n");
> +				cleanup();
> +				tst_exit();
> +		                break;
> +        	}
> +
> +                }
> +        }	
> +        cleanup();
> +	tst_exit();
> +}
> +
> --- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 13:43:32.000000000 +0530
> +++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 13:52:49.000000000 +0530
> @@ -588,6 +588,7 @@ mprotect03 mprotect03
>  mq_notify01 mq_notify01
>  mq_open01 mq_open01
>  mq_timedreceive01 mq_timedreceive01
> +mq_unlink01 mq_unlink01
> 
>  mremap01 mremap01
>  mremap02 mremap02
> 
> ---
> Regards--
> Manas
> 


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [LTP] [PATCH 11/13] Add/Port mq_timedsend01 test for mq_timedsend() syscall
  2009-05-27 10:12 ` [LTP] [PATCH 11/13] Add/Port mq_timedsend01 test for mq_timedsend() syscall Manas Kumar Nayak
@ 2009-05-29 12:57   ` Subrata Modak
  0 siblings, 0 replies; 31+ messages in thread
From: Subrata Modak @ 2009-05-29 12:57 UTC (permalink / raw)
  To: Manas Kumar Nayak; +Cc: LTP List

On Wed, 2009-05-27 at 15:42 +0530, Manas Kumar Nayak wrote: 
> Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>

Thanks.

Regards--
Subrata

> To: LTP List <ltp-list@lists.sourceforge.net>
> Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
> Cc: Masatake YAMATO <yamato@redhat.com>
> ---
> 
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_timedsend/Makefile	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_timedsend/Makefile	2009-05-23 15:08:59.000000000 +0530
> @@ -0,0 +1,31 @@
> +#
> +#  Copyright (c) International Business Machines  Corp., 2009
> +#
> +#  This program is free software;  you can redistribute it and/or modify
> +#  it under the terms of the GNU General Public License as published by
> +#  the Free Software Foundation; either version 2 of the License, or
> +#  (at your option) any later version.
> +#
> +#  This program is distributed in the hope that it will be useful,
> +#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
> +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> +#  the GNU General Public License for more details.
> +#
> +#  You should have received a copy of the GNU General Public License
> +#  along with this program;  if not, write to the Free Software
> +#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#
> +
> +CFLAGS += -I../../../../include -Wall -O2
> +LDLIBS += -L../../../../lib -lltp -lrt
> +
> +SRCS    = $(wildcard *.c)
> +TARGETS = $(patsubst %.c,%,$(SRCS))
> +
> +all: $(TARGETS)
> +
> +install:
> +	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
> +
> +clean:
> +	rm -f $(TARGETS)
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c	2009-05-27 14:11:33.000000000 +0530
> @@ -0,0 +1,539 @@
> +/******************************************************************************/
> +/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
> +/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
> +/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
> +/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
> +/*                                                                  	      */
> +/* This program is free software;  you can redistribute it and/or modify      */
> +/* it under the terms of the GNU General Public License as published by       */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> +/*                                                                            */
> +/******************************************************************************/
> +/******************************************************************************/
> +/*                                                                            */
> +/* File:        mq_timedsend01.c                                              */
> +/*                                                                            */
> +/* Description: This tests the mq_timedsend() syscall                         */
> +/*									      */
> +/* 									      */
> +/*									      */
> +/*									      */
> +/*									      */
> +/*                                                                            */
> +/* Usage:  <for command-line>                                                 */
> +/* mq_timedsend01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                        */
> +/*      where,  -c n : Run n copies concurrently.                             */
> +/*              -e   : Turn on errno logging.                                 */
> +/*              -i n : Execute test n times.                                  */
> +/*              -I x : Execute test for x seconds.                            */
> +/*              -P x : Pause for x seconds between iterations.                */
> +/*              -t   : Turn on syscall timing.                                */
> +/*                                                                            */
> +/* Total Tests: 1                                                             */
> +/*                                                                            */
> +/* Test Name:   mq_timedsend01                                                */
> +/* History:     Porting from Crackerjack to LTP is done by                    */
> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
> +/******************************************************************************/
> +#include <sys/syscall.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <sys/wait.h>
> +#include <getopt.h>
> +#include <stdlib.h>
> +#include <errno.h>
> +#include <stdio.h>
> +#include <unistd.h>
> +#include <string.h>
> +#include <mqueue.h>
> +#include <time.h>
> +#include <signal.h>
> +#include <limits.h>
> +
> +
> +#include "../utils/include_j_h.h"
> +#include "../utils/common_j_h.c"
> +
> +/* Harness Specific Include Files. */
> +#include "test.h"
> +#include "usctest.h"
> +#include "linux_syscall_numbers.h"
> +
> +/* Extern Global Variables */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> +
> +/* Global Variables */
> +char *TCID = "mq_timedsend01";  /* Test program identifier.*/
> +int  testno;
> +int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
> +
> +/* Extern Global Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    cleanup                                                       */
> +/*                                                                            */
> +/* Description: Performs all one time clean up for this test on successful    */
> +/*              completion,  premature exit or  failure. Closes all temporary */
> +/*              files, removes all temporary directories exits the test with  */
> +/*              appropriate return code by calling tst_exit() function.       */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> +/*              On success - Exits calling tst_exit(). With '0' return code.  */
> +/*                                                                            */
> +/******************************************************************************/
> +extern void cleanup() {
> +        /* Remove tmp dir and all files in it */
> +        TEST_CLEANUP;
> +        tst_rmdir();
> +
> +        /* Exit with appropriate return code. */
> +        tst_exit();
> +}
> +
> +/* Local  Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    setup                                                         */
> +/*                                                                            */
> +/* Description: Performs all one time setup for this test. This function is   */
> +/*              typically used to capture signals, create temporary dirs      */
> +/*              and temporary files that may be used in the course of this    */
> +/*              test.                                                         */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits by calling cleanup().                      */
> +/*              On success - returns 0.                                       */
> +/*                                                                            */
> +/******************************************************************************/
> +void setup() {
> +        /* Capture signals if any */
> +        /* Create temporary directories */
> +        TEST_PAUSE;
> +        tst_tmpdir();
> +}
> +
> +
> +/*
> + * Macros
> + */
> +#define SYSCALL_NAME    "mq_timedsend"
> +
> +
> +/*
> + * Global variables
> + */
> +static int opt_debug;
> +static char *progname;
> +
> +enum test_type {
> +		NORMAL,
> +		FD_NONE,
> +	        FD_NOT_EXIST,
> +        	FD_FILE,
> +	        FULL_QUEUE,
> +        	SEND_SIGINT,
> +};
> +
> +/*
> + * Data Structure
> + */
> +struct test_case {
> +	int ttype;
> +        int non_block;
> +        int len;
> +        unsigned prio;
> +        time_t sec;
> +        long nsec;
> +        int ret;
> +        int err;
> +};
> +
> +#define MAX_MSG         10
> +#define MAX_MSGSIZE     8192
> +
> +/* Test cases
> +*
> +*   test status of errors on man page
> +*
> +*   EAGAIN             v (would block)
> +*   EBADF              v (not a valid descriptor)
> +*   EINTR              v (interrupted by a signal)
> +*   EINVAL             v (1. invalid 'msg_prio' or
> +*                         2. would block but timeout exists)
> +*   EMSGSIZE           v ('msg_len' exceeds the message size of the queue)
> +*   ETIMEDOUT          v (not block and timeout occured)
> +*/
> +
> +static struct test_case tcase[] = {
> +	{ // case00
> +                .ttype          = NORMAL,
> +                .len            = 0,    // also success when size equals zero
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case01
> +                .ttype          = NORMAL,
> +                .len            = 1,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case02
> +                .ttype          = NORMAL,
> +                .len            = MAX_MSGSIZE,
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case03
> +                .ttype          = NORMAL,
> +                .len            = 1,
> +                .prio           = 32767, // max priority
> +                .ret            = 0,
> +                .err            = 0,
> +        },
> +        { // case04
> +                .ttype          = NORMAL,
> +                .len            = MAX_MSGSIZE + 1,
> +                .ret            = -1,
> +                .err            = EMSGSIZE,
> +        },
> +	{ // case05
> +                .ttype          = FD_NONE,
> +                .len            = 0,
> +                .ret            = -1,
> +                .err            = EBADF,
> +        },
> +        { // case06
> +                .ttype          = FD_NOT_EXIST,
> +                .len            = 0,
> +                .ret            = -1,
> +                .err            = EBADF,
> +        },
> +        { // case07
> +                .ttype          = FD_FILE,
> +                .len            = 0,
> +                .ret            = -1,
> +                .err            = EBADF,
> +        },
> +        { // case08
> +                .ttype          = FULL_QUEUE,
> +                .non_block      = 1,
> +                .len            = 16,
> +                .ret            = -1,
> +                .err            = EAGAIN,
> +        },
> +	{ // case09
> +                .ttype          = NORMAL,
> +                .len            = 1,
> +                .prio           = 32768, // max priority + 1
> +                .ret            = -1,
> +                .err            = EINVAL,
> +        },
> +        { // case10
> +                .ttype          = FULL_QUEUE,
> +                .len            = 16,
> +                .sec            = -1,
> +                .nsec           = 0,
> +                .ret            = -1,
> +                .err            = EINVAL,
> +        },
> +        { // case11
> +                .ttype          = FULL_QUEUE,
> +                .len            = 16,
> +                .sec            = 0,
> +                .nsec           = -1,
> +                .ret            = -1,
> +                .err            = EINVAL,
> +        },
> +        { // case12
> +                .ttype          = FULL_QUEUE,
> +                .len            = 16,
> +                .sec            = 0,
> +                .nsec           = 1000000000,
> +                .ret            = -1,
> +                .err            = EINVAL,
> +        },
> +	{ // case13
> +                .ttype          = FULL_QUEUE,
> +                .len            = 16,
> +                .sec            = 0,
> +                .nsec           = 999999999,
> +                .ret            = -1,
> +                .err            = ETIMEDOUT,
> +        },
> +        { // case14
> +                .ttype          = SEND_SIGINT,
> +                .len            = 16,
> +                .ret            = -1,
> +                .err            = EINTR,
> +        },
> +};
> +
> +
> +/*
> + * do_test()
> + *
> + *   Input  : TestCase Data
> + *   Return : RESULT_OK(0), RESULT_NG(1)
> + *
> + */
> +
> +static int do_test(struct test_case *tc)
> +{
> +        int sys_ret;
> +        int sys_errno;
> +        int result = RESULT_OK;
> +	int oflag;
> +        int i, rc, cmp_ok = 1, fd = -1;
> +        char smsg[MAX_MSGSIZE], rmsg[MAX_MSGSIZE];
> +        struct timespec ts, *p_ts;
> +        pid_t pid = 0;
> +        unsigned prio;
> +
> +        /*
> +         * When test ended with SIGTERM etc, mq discriptor is left remains.
> +         * So we delete it first.
> +         */
> +        TEST(mq_unlink(QUEUE_NAME));
> +
> +        switch (tc->ttype) {
> +        case FD_NOT_EXIST:
> +                fd = INT_MAX - 1;
> +                /* fallthrough */
> +        case FD_NONE:
> +                break;
> +	case FD_FILE:
> +                TEST(fd = open("/", O_RDONLY));
> +                if (fd < 0) {
> +                 	tst_resm(TFAIL, "can't open \"/\".- errno = %d : %s\n", TEST_ERRNO, strerror(TEST_ERRNO));
> +                        result = 1;
> +                        goto EXIT;
> +                }
> +                break;
> +        default:
> +                /*
> +                 * Open message queue
> +                 */
> +                oflag = O_CREAT|O_EXCL|O_RDWR;
> +                if (tc->non_block)
> +                        oflag |= O_NONBLOCK;
> +
> +                TEST(fd = mq_open(QUEUE_NAME, oflag, S_IRWXU, NULL));
> +                if (TEST_RETURN < 0) {
> +                 	tst_resm(TFAIL, "mq_open failed - errno = %d : %s\n", TEST_ERRNO, strerror(TEST_ERRNO));
> +                        result = 1;
> +                        goto EXIT;
> +                }
> +                if (tc->ttype == FULL_QUEUE || tc->ttype == SEND_SIGINT) {
> +                        for (i = 0; i < MAX_MSG; i++) {
> +                                TEST(rc = mq_timedsend(fd, smsg, tc->len, 0, NULL));
> +                                if (rc < 0) {
> +                 	   		tst_resm(TFAIL, "mq_timedsend failed - errno = %d : %s\n",TEST_ERRNO, strerror(TEST_ERRNO));
> +                                        result = 1;
> +                                        goto EXIT;
> +                                }
> +                        }
> +			if (tc->ttype == SEND_SIGINT) {
> +                                TEST(pid = create_sig_proc(200000, SIGINT));
> +                                if (TEST_RETURN < 0) {
> +                                        result = 1;
> +                                        goto EXIT;
> +                                }
> +                        }
> +                }
> +                break;
> +        }
> +
> +        /*
> +         * Prepare send message
> +         */
> +        for (i = 0; i < tc->len; i++)
> +                smsg[i] = i;
> +
> +        /*
> +         * Set the timeout value
> +         */
> +        ts.tv_sec = tc->sec;
> +        ts.tv_nsec = tc->nsec;
> +        p_ts = &ts;
> +        if (tc->sec == 0 && tc->nsec == 0)
> +                p_ts = NULL;
> +
> +        /*
> +        * Execut test system call
> +         */
> +        errno = 0;
> +        TEST(sys_ret = mq_timedsend(fd, smsg, tc->len, tc->prio, p_ts));
> +        sys_errno = errno;
> +        if (sys_ret < 0)
> +                goto TEST_END;
> +
> +        /*
> +         * Receive echoed message and compare
> +         */
> +        TEST(rc = mq_timedreceive(fd, rmsg, MAX_MSGSIZE, &prio, NULL));
> +        if (rc < 0) {
> +                tst_resm(TFAIL, "mq_timedreceive failed - errno = %d : %s\n",TEST_ERRNO, strerror(TEST_ERRNO));
> +                result = 1;
> +                goto EXIT;
> +        }
> +        if (rc != tc->len || tc->prio != prio)
> +                cmp_ok = 0;
> +        else {
> +                for (i = 0; i < tc->len; i++)
> +                        if (rmsg[i] != smsg[i]) {
> +                                cmp_ok = 0;
> +                                break;
> +                        }
> +        }
> +TEST_END:
> +        /*
> +         * Check results
> +         */
> +        result |= (sys_errno != tc->err) || !cmp_ok;
> +        PRINT_RESULT_CMP(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno,cmp_ok);
> +
> +EXIT:
> +        if (fd >= 0) {
> +                TEST(close(fd));
> +                TEST(mq_unlink(QUEUE_NAME));
> +        }
> +        if (pid > 0) {
> +                int st;
> +                kill(pid, SIGTERM);
> +                wait(&st);
> +        }
> +        exit(result);
> +}
> +
> +
> +/*
> + * sighandler()
> + */
> +void sighandler(int sig)
> +{
> +        if (sig == SIGINT)
> +                return;
> +        // NOTREACHED
> +        return;
> +}
> +
> +
> +/*
> + * usage()
> + */
> +
> +static void usage(const char *progname)
> +{
> +        tst_resm(TINFO,"usage: %s [options]\n", progname);
> +        tst_resm(TINFO,"This is a regression test program of %s system call.\n",SYSCALL_NAME);
> +        tst_resm(TINFO,"options:\n");
> +        tst_resm(TINFO,"    -d --debug           Show debug messages\n");
> +        tst_resm(TINFO,"    -h --help            Show this message\n");
> +        tst_resm(TINFO,"NG\n");
> +        exit(1);
> +}
> +
> +
> +/*
> + * main()
> + */
> +
> +
> +
> +int main(int ac, char **av) {
> +	int result = RESULT_OK;
> +        int c;
> +        int i;
> +        int lc;                 /* loop counter */
> +        char *msg;              /* message returned from parse_opts */
> +
> +	struct option long_options[] = {
> +                { "debug", no_argument, 0, 'd' },
> +                { "help",  no_argument, 0, 'h' },
> +                { NULL, 0, NULL, 0 }
> +        };
> +
> +	progname = strchr(av[0], '/');
> +        progname = progname ? progname + 1 : av[0];	
> +	
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> +
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
> +			 while(TEST_RETURN != -1) {
> +		                switch (c) {
> +                		case 'd':
> +		                        opt_debug = 1;
> +                		        break;
> +		                default:
> +                		        usage(progname);
> +                        		// NOTREACHED
> +                		}
> +		        }
> +
> +
> +		if (ac != optind) {
> +        	        tst_resm(TINFO,"Options are not match.");
> +                	usage(progname);
> +                	// NOTREACHED
> +	        }
> +		/*
> +        	 * Execute test
> +        	 */
> +        	signal(SIGINT, sighandler);
> +
> +	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
> +        	        int ret;
> +	                tst_resm(TINFO,"(case%02d) START", i);
> +	                ret = do_test(&tcase[i]);
> +	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
> +	                result |= ret;
> +        	}
> +		/*	
> +        	 * Check results
> +         	*/
> +        	switch(result) {
> +	        case RESULT_OK:
> +        			tst_resm(TPASS, "mq_timedsend call succeeded");
> +		                break;
> +
> +	        default:
> +                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
> +        		        RPRINTF("NG\n");
> +				cleanup();
> +				tst_exit();
> +        	}
> +
> +                }
> +        }	
> +        cleanup();
> +	tst_exit();
> +}
> +
> --- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 13:55:49.000000000 +0530
> +++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 14:13:17.000000000 +0530
> @@ -588,6 +588,7 @@ mprotect03 mprotect03
>  mq_notify01 mq_notify01
>  mq_open01 mq_open01
>  mq_timedreceive01 mq_timedreceive01
> +mq_timedsend01 mq_timedsend01
>  mq_unlink01 mq_unlink01
> 
>  mremap01 mremap01
> 
> ---
> Regards--
> Manas
> 


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [LTP] [PATCH 12/13] Add/Port unshare01 test for unshare() syscall
  2009-05-27 10:12 ` [LTP] [PATCH 12/13] Add/Port unshare01 test for unshare() syscall Manas Kumar Nayak
@ 2009-05-29 12:57   ` Subrata Modak
  0 siblings, 0 replies; 31+ messages in thread
From: Subrata Modak @ 2009-05-29 12:57 UTC (permalink / raw)
  To: Manas Kumar Nayak; +Cc: LTP List

On Wed, 2009-05-27 at 15:42 +0530, Manas Kumar Nayak wrote: 
> Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>

Thanks.

Regards--
Subrata

> To: LTP List <ltp-list@lists.sourceforge.net>
> Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
> Cc: Masatake YAMATO <yamato@redhat.com>
> ---
> 
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/unshare/Makefile	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/unshare/Makefile	2009-05-25 15:12:47.000000000 +0530
> @@ -0,0 +1,31 @@
> +#
> +#  Copyright (c) International Business Machines  Corp., 2009
> +#
> +#  This program is free software;  you can redistribute it and/or modify
> +#  it under the terms of the GNU General Public License as published by
> +#  the Free Software Foundation; either version 2 of the License, or
> +#  (at your option) any later version.
> +#
> +#  This program is distributed in the hope that it will be useful,
> +#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
> +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> +#  the GNU General Public License for more details.
> +#
> +#  You should have received a copy of the GNU General Public License
> +#  along with this program;  if not, write to the Free Software
> +#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#
> +
> +CFLAGS += -I../../../../include -Wall
> +LDLIBS += -L../../../../lib -lltp
> +
> +SRCS    = $(wildcard *.c)
> +TARGETS = $(patsubst %.c,%,$(SRCS))
> +
> +all: $(TARGETS)
> +
> +install:
> +	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
> +
> +clean:
> +	rm -f $(TARGETS)
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/unshare/unshare01.c	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/unshare/unshare01.c	2009-05-27 14:43:04.000000000 +0530
> @@ -0,0 +1,231 @@
> +/********************************************************************************/
> +/* Copyright (c) Crackerjack Project., 2007                                   	*/
> +/*                                                                            	*/
> +/* This program is free software;  you can redistribute it and/or modify      	*/
> +/* it under the terms of the GNU General Public License as published by       	*/
> +/* the Free Software Foundation; either version 2 of the License, or          	*/
> +/* (at your option) any later version.                                        	*/
> +/*                                                                            	*/
> +/* This program is distributed in the hope that it will be useful,            	*/
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            	*/
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  	*/
> +/* the GNU General Public License for more details.                           	*/
> +/*                                                                            	*/
> +/* You should have received a copy of the GNU General Public License          	*/
> +/* along with this program;  if not, write to the Free Software               	*/
> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    	*/
> +/*                                                                            	*/
> +/******************************************************************************	*/
> +/******************************************************************************	*/
> +/*                                                                            	*/
> +/* File:        unshare01.c                                           	      	*/
> +/*                                                                            	*/
> +/* Description: This tests the unshare() syscall.                      	      	*/
> +/*             unshare() allows a process to disassociate parts of its 		*/
> +/*		execution context that are currently being shared with other 	*/
> +/*		processes. Part of the execution context, such as the namespace	*/
> +/*		,is shared implicitly when a new process is created using 	*/
> +/*		fork(2) or vfork(2), while other parts, such as virtual memory	*/
> +/*		, may be shared by explicit request when creating a process 	*/
> +/*		using clone(2).							*/
> +/*										*/
> +/*		The main use of unshare() is to allow a process to control its	*/ 
> +/*		shared execution context without creating a new process.	*/
> +/*	         								*/
> +/*										*/
> +/*		The flags argument is a bit mask that specifies which parts of	*/
> +/*		the execution context should be unshared. This argument is 	*/
> +/*		specified by ORing together zero or more of the following cons-	*/
> +/*		tants:								*/
> +/*										*/
> +/*		CLONE_FILES:							*/
> +/*		    	Reverse the effect of the clone(2) CLONE_FILES flag. 	*/
> +/*			Unshare	the file descriptor table, so that the calling 	*/
> +/*			process no longer shares its file descriptors with any 	*/
> +/*			other process.						*/
> +/*		CLONE_FS:							*/
> +/*			Reverse the effect of the clone(2) CLONE_FS flag.Unshare*/
> +/*			file system attributes, so that the calling process no 	*/
> +/*			longer shares its root directory, current directory, or	*/
> +/*			umask attributes with any other process.		*/
> +/*		CLONE_NEWNS:							*/
> +/*		       This flag has the same effect as the clone(2) CLONE_NEWNS*/ 
> +/*			flag. Unshare the namespace, so that the calling process*/ 
> +/*			has a private copy of its namespacei which is not shared*/
> +/*			with any other process. Specifying this flag automat-	*/
> +/*			ically implies CLONE_FS as well. 			*/
> +/*										*/
> +/*		If flags is specified as zero, then unshare() is a no-op; no 	*/
> +/*		changes are made to the calling process's execution context. 	*/
> +/*		                                                               	*/
> +/* Usage:  <for command-line>                                                 	*/
> +/* unshare01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                     		*/
> +/*      where,  -c n : Run n copies concurrently.                             	*/
> +/*              -e   : Turn on errno logging.                                 	*/
> +/*              -i n : Execute test n times.                                  	*/
> +/*              -I x : Execute test for x seconds.                            	*/
> +/*              -P x : Pause for x seconds between iterations.                	*/
> +/*              -t   : Turn on syscall timing.                                	*/
> +/*                                                                            	*/
> +/* Total Tests: 1                                                             	*/
> +/*                                                                            	*/
> +/* Test Name:   unshare01                                             		*/
> +/* History:     Porting from Crackerjack to LTP is done by                    	*/
> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        	*/
> +/********************************************************************************/
> +
> +#include <stdio.h>
> +#include <sys/wait.h>
> +#include <sys/types.h>
> +#include <sched.h>
> +#include <limits.h>
> +#include <unistd.h>
> +#include <sys/types.h>
> +#include <sys/syscall.h>
> +#include <errno.h>
> +#include <pwd.h>
> +#include <grp.h>
> +#include <string.h>
> +#include <sys/param.h>
> +#include <stdio.h>
> +
> +/* Harness Specific Include Files. */
> +#include "test.h"
> +#include "usctest.h"
> +#include "linux_syscall_numbers.h"
> +
> +/* Extern Global Variables */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> +
> +/* Global Variables */
> +char *TCID = "unshare01";  /* Test program identifier.*/
> +int  testno;
> +int  TST_TOTAL =1;                   /* total number of tests in this file.   */
> +
> +/* Extern Global Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    cleanup                                                       */
> +/*                                                                            */
> +/* Description: Performs all one time clean up for this test on successful    */
> +/*              completion,  premature exit or  failure. Closes all temporary */
> +/*              files, removes all temporary directories exits the test with  */
> +/*              appropriate TEST_RETURNurn code by calling tst_exit() function.       */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits calling tst_exit(). Non '0' TEST_RETURNurn code.   */
> +/*              On success - Exits calling tst_exit(). With '0' TEST_RETURNurn code.  */
> +/*                                                                            */
> +/******************************************************************************/
> +extern void cleanup() {
> +        /* Remove tmp dir and all files in it */
> +        TEST_CLEANUP;
> +        tst_rmdir();
> +
> +        /* Exit with appropriate TEST_RETURNurn code. */
> +        tst_exit();
> +}
> +
> +/* Local  Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    setup                                                         */
> +/*                                                                            */
> +/* Description: Performs all one time setup for this test. This function is   */
> +/*              typically used to capture signals, create temporary dirs      */
> +/*              and temporary files that may be used in the course of this    */
> +/*              test.                                                         */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits by calling cleanup().                      */
> +/*              On success - TEST_RETURNurns 0.                                       */
> +/*                                                                            */
> +/******************************************************************************/
> +void setup() {
> +        /* Capture signals if any */
> +        /* Create temporary directories */
> +        TEST_PAUSE;
> +        tst_tmpdir();
> +}
> +
> +int main(int ac, char **av) {
> +        pid_t pid1;
> +	int lc;                 /* loop counter */
> +        char *msg;              /* message TEST_RETURNurned from parse_opts */
> +	
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> +
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +
> + /*
> + *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));
> +				cleanup();
> +				tst_exit();
> +			}else if (TEST_RETURN == 0){
> +				if((TEST_RETURN = unshare(CLONE_FILES)) == 0) {
> +	        		tst_resm(TPASS, "unshare with CLONE_FILES call succeeded");
> +				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));
> +	                        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{
> +			}
> +
> +			TEST(pid1=fork());    //call to fork()
> +                        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{
> +			}
> +
> +
> +                }
> +
> +                }
> +	cleanup();
> +	tst_exit();
> +}
> +
> --- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 14:45:49.000000000 +0530
> +++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 14:45:21.000000000 +0530
> @@ -1207,6 +1207,8 @@ unlink08 unlink08
>  #unlinkat test cases
>  unlinkat01 unlinkat01
> 
> +unshare01 unshare01
> +
>  #
>  # These tests require an unmounted block device
>  # to run correctly. Please see individual test
> 
> ---
> Regards--
> Manas
> 


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [LTP] [PATCH 13/13] Add/Port unshare02 test for unshare() syscall
  2009-05-27 10:13 ` [LTP] [PATCH 13/13] Add/Port unshare02 " Manas Kumar Nayak
@ 2009-05-29 12:57   ` Subrata Modak
  0 siblings, 0 replies; 31+ messages in thread
From: Subrata Modak @ 2009-05-29 12:57 UTC (permalink / raw)
  To: Manas Kumar Nayak; +Cc: LTP List

On Wed, 2009-05-27 at 15:43 +0530, Manas Kumar Nayak wrote: 
> Signed-off-by: Manas Kumar Nayak <maknayak@in.ibm.com>

Thanks.

Regards--
Subrata

> To: LTP List <ltp-list@lists.sourceforge.net>
> Cc: Subrata Modak <subrata@linux.vnet.ibm.com>
> Cc: Masatake YAMATO <yamato@redhat.com>
> ---
> 
> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/unshare/unshare02.c	1970-01-01 05:30:00.000000000 +0530
> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/unshare/unshare02.c	2009-05-27 14:51:53.000000000 +0530
> @@ -0,0 +1,183 @@
> +/******************************************************************************/
> +/* Copyright (c) Crackerjack Project., 2007                                   */
> +/*                                                                            */
> +/* This program is free software;  you can redistribute it and/or modify      */
> +/* it under the terms of the GNU General Public License as published by       */
> +/* the Free Software Foundation; either version 2 of the License, or          */
> +/* (at your option) any later version.                                        */
> +/*                                                                            */
> +/* This program is distributed in the hope that it will be useful,            */
> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> +/* the GNU General Public License for more details.                           */
> +/*                                                                            */
> +/* You should have received a copy of the GNU General Public License          */
> +/* along with this program;  if not, write to the Free Software               */
> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> +/*                                                                            */
> +/******************************************************************************/
> +/******************************************************************************/
> +/*                                                                            */
> +/* File:        unshare02.c                                                   */
> +/*                                                                            */
> +/* Description: This tests the unshare error() syscall                        */
> +/*                                                                            */
> +/* Usage:  <for command-line>                                                 */
> +/* unshare02 [-c n] [-e][-i n] [-I x] [-p x] [-t]                             */
> +/*      where,  -c n : Run n copies concurrently.                             */
> +/*              -e   : Turn on errno logging.                                 */
> +/*              -i n : Execute test n times.                                  */
> +/*              -I x : Execute test for x seconds.                            */
> +/*              -P x : Pause for x seconds between iterations.                */
> +/*              -t   : Turn on syscall timing.                                */
> +/*                                                                            */
> +/* Total Tests: 2                                                             */
> +/*                                                                            */
> +/* Test Name:   unshare02                                                     */
> +/* History:     Porting from Crackerjack to LTP is done by                    */
> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
> +/******************************************************************************/
> +
> +#include <stdio.h>
> +#include <sys/wait.h>
> +#include <sys/types.h>
> +#include <sched.h>
> +#include <limits.h>
> +#include <unistd.h>
> +#include <sys/types.h>
> +#include <sys/syscall.h>
> +#include <errno.h>
> +#include <pwd.h>
> +#include <grp.h>
> +#include <string.h>
> +#include <sys/param.h>
> +#include <stdio.h>
> +
> +/* Harness Specific Include Files. */
> +#include "test.h"
> +#include "usctest.h"
> +#include "linux_syscall_numbers.h"
> +
> +/* Extern Global Variables */
> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> +
> +/* Global Variables */
> +char *TCID = "unshare02";  /* Test program identifier.*/
> +int  testno;
> +int  TST_TOTAL = 2;                   /* total number of tests in this file.   */
> +
> +/* Extern Global Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    cleanup                                                       */
> +/*                                                                            */
> +/* Description: Performs all one time clean up for this test on successful    */
> +/*              completion,  premature exit or  failure. Closes all temporary */
> +/*              files, removes all temporary directories exits the test with  */
> +/*              appropriate TEST_RETURNurn code by calling tst_exit() function.       */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits calling tst_exit(). Non '0' TEST_RETURNurn code.   */
> +/*              On success - Exits calling tst_exit(). With '0' TEST_RETURNurn code.  */
> +/*                                                                            */
> +/******************************************************************************/
> +extern void cleanup() {
> +        /* Remove tmp dir and all files in it */
> +        TEST_CLEANUP;
> +        tst_rmdir();
> +
> +        /* Exit with appropriate TEST_RETURNurn code. */
> +        tst_exit();
> +}
> +
> +/* Local  Functions */
> +/******************************************************************************/
> +/*                                                                            */
> +/* Function:    setup                                                         */
> +/*                                                                            */
> +/* Description: Performs all one time setup for this test. This function is   */
> +/*              typically used to capture signals, create temporary dirs      */
> +/*              and temporary files that may be used in the course of this    */
> +/*              test.                                                         */
> +/*                                                                            */
> +/* Input:       None.                                                         */
> +/*                                                                            */
> +/* Output:      None.                                                         */
> +/*                                                                            */
> +/* Return:      On failure - Exits by calling cleanup().                      */
> +/*              On success - TEST_RETURNurns 0.                                       */
> +/*                                                                            */
> +/******************************************************************************/
> +void setup() {
> +        /* Capture signals if any */
> +        /* Create temporary directories */
> +        TEST_PAUSE;
> +        tst_tmpdir();
> +}
> +
> +int main(int ac, char **av) {
> +        pid_t pid1;
> +	int lc;                 /* loop counter */
> +        char *msg;              /* message TEST_RETURNurned from parse_opts */
> +	
> +        /* parse standard options */
> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +             tst_exit();
> +           }
> +
> +        setup();
> +
> +        /* Check looping state if -i option given */
> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> +                Tst_count = 0;
> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> +
> + /*
> + *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));
> +			cleanup();
> +			tst_exit();
> +			}
> +			else if (TEST_RETURN == 0){
> +				if((TEST_RETURN = unshare(-1)) == 0) {
> +	        		tst_resm(TPASS, "Call succeeded");
> +				tst_exit();
> +				}
> +				else if (TEST_RETURN == -1 ){
> +					tst_resm(TFAIL,"Test Failed, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +					tst_exit();
> +                     			}
> +			}
> +
> +			TEST(pid1=fork());    //call to fork()
> +                        if (pid1 == -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((int)NULL)) == 0) {
> +                                tst_resm(TPASS, "Call succeeded");
> +				tst_exit();
> +                                }
> +                                else if (TEST_RETURN == -1 ){
> +                                        tst_resm(TFAIL,"Test Failed 2, errno=%d : %s",TEST_ERRNO, strerror(TEST_ERRNO));
> +					tst_exit();
> +                                        }
> +                        }
> +
> +
> +                }
> +	}
> +	cleanup();
> +        tst_exit();
> +}
> +
> --- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 14:49:30.000000000 +0530
> +++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 14:57:51.000000000 +0530
> @@ -1208,6 +1208,7 @@ unlink08 unlink08
>  unlinkat01 unlinkat01
> 
>  unshare01 unshare01
> +unshare02 unshare02
> 
>  #
>  # These tests require an unmounted block device
> 
> ---
> Regards--
> Manas
> 


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [LTP] [PATCH 06/13]  Add/Port ppoll01 test for ppoll() syscall
  2009-05-29 12:56   ` Subrata Modak
@ 2009-08-06  9:56     ` Michal Simek
  2009-08-07 12:41       ` Subrata Modak
  0 siblings, 1 reply; 31+ messages in thread
From: Michal Simek @ 2009-08-06  9:56 UTC (permalink / raw)
  To: subrata; +Cc: LTP List, Manas Kumar Nayak

Hi,

I am getting fault on x86/Microblaze for ppoll. It is run only one
testcase than ends.
Have you ever met with this problem?

Thanks,
Michal

[monstr@monstr ppoll]$ ./ppoll01
ppoll01     0  TINFO  :  (case00) START
EXPECT: return value(ret)=(N >= 0) errno=0 (Success), r/w check=OK
RESULT: return value(ret)=       1 errno=0 (Success), r/w check=NG
ppoll01     0  TINFO  :  (case00) END => NG
ppoll01     0  TINFO  :  (case01) START

[monstr@monstr ppoll]$ echo $?
130
[monstr@monstr ppoll]$


> Thanks.
>
> Regards--
> Subrata
>
> On Wed, 2009-05-27 at 15:39 +0530, Manas Kumar Nayak wrote: 
>   
>> diff -uprN ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/Makefile ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/Makefile
>> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/Makefile	1970-01-01 05:30:00.000000000 +0530
>> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/Makefile	2009-05-23 12:01:25.000000000 +0530
>> @@ -0,0 +1,31 @@
>> +#
>> +#  Copyright (c) International Business Machines  Corp., 2009
>> +#
>> +#  This program is free software;  you can redistribute it and/or modify
>> +#  it under the terms of the GNU General Public License as published by
>> +#  the Free Software Foundation; either version 2 of the License, or
>> +#  (at your option) any later version.
>> +#
>> +#  This program is distributed in the hope that it will be useful,
>> +#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
>> +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
>> +#  the GNU General Public License for more details.
>> +#
>> +#  You should have received a copy of the GNU General Public License
>> +#  along with this program;  if not, write to the Free Software
>> +#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
>> +#
>> +
>> +CFLAGS += -I../../../../include -Wall -O2
>> +LDLIBS += -L../../../../lib -lltp 
>> +
>> +SRCS    = $(wildcard *.c)
>> +TARGETS = $(patsubst %.c,%,$(SRCS))
>> +
>> +all: $(TARGETS)
>> +
>> +install:
>> +	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
>> +
>> +clean:
>> +	rm -f $(TARGETS)
>> diff -uprN ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/ppoll01.c ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/ppoll01.c
>> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/ppoll01.c	1970-01-01 05:30:00.000000000 +0530
>> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/ppoll01.c	2009-05-27 13:00:58.000000000 +0530
>> @@ -0,0 +1,482 @@
>> +/******************************************************************************/
>> +/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
>> +/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
>> +/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
>> +/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
>> +/*                                                                  	      */
>> +/* This program is free software;  you can redistribute it and/or modify      */
>> +/* it under the terms of the GNU General Public License as published by       */
>> +/* the Free Software Foundation; either version 2 of the License, or          */
>> +/* (at your option) any later version.                                        */
>> +/*                                                                            */
>> +/* This program is distributed in the hope that it will be useful,            */
>> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
>> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
>> +/* the GNU General Public License for more details.                           */
>> +/*                                                                            */
>> +/* You should have received a copy of the GNU General Public License          */
>> +/* along with this program;  if not, write to the Free Software               */
>> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
>> +/*                                                                            */
>> +/******************************************************************************/
>> +/******************************************************************************/
>> +/*                                                                            */
>> +/* File:        ppoll01.c                                                     */
>> +/*                                                                            */
>> +/* Description: This tests the ppoll01() syscall                              */
>> +/*									      */
>> +/* 									      */
>> +/*									      */
>> +/*									      */
>> +/*									      */
>> +/*                                                                            */
>> +/* Usage:  <for command-line>                                                 */
>> +/* ppoll01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                               */
>> +/*      where,  -c n : Run n copies concurrently.                             */
>> +/*              -e   : Turn on errno logging.                                 */
>> +/*              -i n : Execute test n times.                                  */
>> +/*              -I x : Execute test for x seconds.                            */
>> +/*              -P x : Pause for x seconds between iterations.                */
>> +/*              -t   : Turn on syscall timing.                                */
>> +/*                                                                            */
>> +/* Total Tests: 1                                                             */
>> +/*                                                                            */
>> +/* Test Name:   ppoll01                                                       */
>> +/* History:     Porting from Crackerjack to LTP is done by                    */
>> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
>> +/******************************************************************************/
>> +#include <sys/syscall.h>
>> +#include <sys/types.h>
>> +#include <sys/select.h>
>> +#include <sys/wait.h>
>> +#include <getopt.h>
>> +#include <string.h>
>> +#include <stdlib.h>
>> +#include <errno.h>
>> +#include <stdio.h>
>> +#include <unistd.h>
>> +#include <fcntl.h>
>> +#include <libgen.h>
>> +#include <limits.h>
>> +#include <signal.h>
>> +#include "asm/poll.h"
>> +
>> +
>> +#include "../utils/include_j_h.h"
>> +#include "../utils/common_j_h.c"
>> +
>> +/* Harness Specific Include Files. */
>> +#include "test.h"
>> +#include "usctest.h"
>> +#include "linux_syscall_numbers.h"
>> +
>> +/* Extern Global Variables */
>> +extern int Tst_count;           /* counter for tst_xxx routines.         */
>> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
>> +
>> +/* Global Variables */
>> +char *TCID = "ppoll01";  /* Test program identifier.*/
>> +int  testno;
>> +int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
>> +
>> +/* Extern Global Functions */
>> +/******************************************************************************/
>> +/*                                                                            */
>> +/* Function:    cleanup                                                       */
>> +/*                                                                            */
>> +/* Description: Performs all one time clean up for this test on successful    */
>> +/*              completion,  premature exit or  failure. Closes all temporary */
>> +/*              files, removes all temporary directories exits the test with  */
>> +/*              appropriate return code by calling tst_exit() function.       */
>> +/*                                                                            */
>> +/* Input:       None.                                                         */
>> +/*                                                                            */
>> +/* Output:      None.                                                         */
>> +/*                                                                            */
>> +/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
>> +/*              On success - Exits calling tst_exit(). With '0' return code.  */
>> +/*                                                                            */
>> +/******************************************************************************/
>> +extern void cleanup() {
>> +        /* Remove tmp dir and all files in it */
>> +        TEST_CLEANUP;
>> +        tst_rmdir();
>> +
>> +        /* Exit with appropriate return code. */
>> +        tst_exit();
>> +}
>> +
>> +/* Local  Functions */
>> +/******************************************************************************/
>> +/*                                                                            */
>> +/* Function:    setup                                                         */
>> +/*                                                                            */
>> +/* Description: Performs all one time setup for this test. This function is   */
>> +/*              typically used to capture signals, create temporary dirs      */
>> +/*              and temporary files that may be used in the course of this    */
>> +/*              test.                                                         */
>> +/*                                                                            */
>> +/* Input:       None.                                                         */
>> +/*                                                                            */
>> +/* Output:      None.                                                         */
>> +/*                                                                            */
>> +/* Return:      On failure - Exits by calling cleanup().                      */
>> +/*              On success - returns 0.                                       */
>> +/*                                                                            */
>> +/******************************************************************************/
>> +void setup() {
>> +        /* Capture signals if any */
>> +        /* Create temporary directories */
>> +        TEST_PAUSE;
>> +        tst_tmpdir();
>> +}
>> +
>> +
>> +/*
>> + * Macros
>> + */
>> +#define SYSCALL_NAME    "ppoll"
>> +
>> +#ifndef __NR_ppoll
>> +#  define __NR_ppoll    309
>> +#endif
>> +
>> +#ifndef POLLRDHUP
>> +#  define POLLRDHUP     0x2000
>> +#endif
>> +
>> +
>> +/*
>> + * Global variables
>> + */
>> +static int opt_debug;
>> +static char *progname;
>> +static char *progdir;
>> +
>> +enum test_type {
>> +	NORMAL,
>> +        MASK_SIGNAL,
>> +        TIMEOUT,
>> +        FD_ALREADY_CLOSED,
>> +        SEND_SIGINT,
>> +        INVALID_NFDS,
>> +        INVALID_FDS,
>> +        MINUS_NSEC,
>> +        TOO_LARGE_NSEC,
>> +
>> +};
>> +
>> +
>> +/*
>> + * Data Structure
>> + */
>> +struct test_case {
>> +	short expect_revents;
>> +        int ttype;
>> +        int ret;
>> +        int err;
>> +};
>> +
>> +
>> +/* Test cases
>> + *
>> + *   test status of errors on man page
>> + *
>> + *   EBADF              can't check because EBADF never happen even though
>> + *                      fd was invalid. In this case, information of invalid
>> + *                      fd is set in revents
>> + *   EFAULT             v ('fds' array in the invalid address space)
>> + *   EINTR              v (a non blocked signal was caught)
>> + *   EINVAL             v ('nfds' is over the 'RLIMIT_NOFILE' value)
>> + *   ENOMEM             can't check because it's difficult to create no-memory
>> + */
>> +
>> +
>> +static struct test_case tcase[] = {
>> +	{ // case00
>> +                .ttype          = NORMAL,
>> +                .expect_revents = POLLOUT,
>> +                .ret            = 0,
>> +                .err            = 0,
>> +        },
>> +        { // case01
>> +                .ttype          = MASK_SIGNAL,
>> +                .expect_revents = 0, // don't care
>> +                .ret            = 0,
>> +                .err            = 0,
>> +        },
>> +        { // case02
>> +                .ttype          = TIMEOUT,
>> +                .expect_revents = 0, // don't care
>> +                .ret            = 0,
>> +                .err            = 0,
>> +        },
>> +        { // case03
>> +                .ttype          = FD_ALREADY_CLOSED,
>> +                .expect_revents = POLLNVAL,
>> +                .ret            = 0,
>> +                .err            = 0,
>> +        },
>> +        { // case04
>> +                .ttype          = SEND_SIGINT,
>> +                .ret            = -1,
>> +                .err            = EINTR,
>> +        },
>> +        { // case05
>> +                .ttype          = INVALID_NFDS,
>> +                .ret            = -1,
>> +                .err            = EINVAL,
>> +        },
>> +        { // case06
>> +                .ttype          = INVALID_FDS,
>> +                .ret            = -1,
>> +                .err            = EFAULT,
>> +        },
>> +#if 0
>> +        { // case07
>> +                .ttype          = MINUS_NSEC,
>> +                .ret            = -1,
>> +                .err            = EINVAL, // RHEL4U1 + 2.6.18 returns SUCCESS
>> +        },
>> +        { // case08
>> +                .ttype          = TOO_LARGE_NSEC,
>> +                .ret            = -1,
>> +                .err            = EINVAL, // RHEL4U1 + 2.6.18 returns SUCCESS
>> +        },
>> +#endif
>> +};
>> +
>> +#define NUM_TEST_FDS    1
>> +
>> +/*
>> + * do_test()
>> + *
>> + *   Input  : TestCase Data
>> + *   Return : RESULT_OK(0), RESULT_NG(1)
>> + *
>> + */
>> +
>> +static int do_test(struct test_case *tc)
>> +{
>> +        int sys_ret;
>> +        int sys_errno;
>> +        int result = RESULT_OK;
>> +	int fd = -1 , cmp_ok = 1;
>> +	char fpath[PATH_MAX];
>> +	struct pollfd *p_fds, fds[NUM_TEST_FDS];
>> +        unsigned int nfds = NUM_TEST_FDS;
>> +        struct timespec *p_ts, ts;
>> +        sigset_t *p_sigmask, sigmask;
>> +        size_t sigsetsize = 0;
>> +        pid_t pid = 0;
>> +
>> +	TEST(fd = setup_file(progdir, "test.file", fpath));
>> +        if (fd < 0)
>> +                return 1;
>> +        fds[0].fd = fd;
>> +        fds[0].events = POLLIN | POLLPRI | POLLOUT | POLLRDHUP;
>> +        fds[0].revents = 0;
>> +        p_fds = fds;
>> +        p_ts = NULL;
>> +        p_sigmask = NULL;
>> +
>> +	switch (tc->ttype) {
>> +        case TIMEOUT:
>> +                nfds = 0;
>> +                ts.tv_sec = 0;
>> +                ts.tv_nsec = 50000000;  // 50msec
>> +                p_ts = &ts;
>> +                break;
>> +	case FD_ALREADY_CLOSED:
>> +                TEST(close(fd));
>> +                fd = -1;
>> +                TEST(cleanup_file(fpath));
>> +                break;
>> +        case MASK_SIGNAL:
>> +                TEST(sigemptyset(&sigmask));
>> +                TEST(sigaddset(&sigmask, SIGINT));
>> +                p_sigmask = &sigmask;
>> +                //sigsetsize = sizeof(sigmask);
>> +                sigsetsize = 8;
>> +                nfds = 0;
>> +                ts.tv_sec = 0;
>> +                ts.tv_nsec = 300000000; // 300msec => need to be enough for
>> +                                        //   waiting the signal
>> +                p_ts = &ts;
>> +                // fallthrough
>> +	case SEND_SIGINT:
>> +                nfds = 0;
>> +                TEST(pid = create_sig_proc(100000, SIGINT)); // 100msec
>> +                if (pid < 0)
>> +                        return 1;
>> +                break;
>> +        case INVALID_NFDS:
>> +                //nfds = RLIMIT_NOFILE + 1; ==> RHEL4U1 + 2.6.18 returns SUCCESS
>> +                nfds = -1;
>> +                break;
>> +        case INVALID_FDS:
>> +                p_fds = (void*)0xc0000000;
>> +                break;
>> +        case MINUS_NSEC:
>> +                ts.tv_sec = 0;
>> +                ts.tv_nsec = -1;
>> +                p_ts = &ts;
>> +                break;
>> +	case TOO_LARGE_NSEC:
>> +                ts.tv_sec = 0;
>> +                ts.tv_nsec = 1000000000;
>> +                p_ts = &ts;
>> +                break;
>> +        }
>> +
>> +	/*
>> +	   * Execute system call
>> +         */
>> +        errno = 0;
>> +        TEST(sys_ret = syscall(__NR_ppoll, p_fds, nfds, p_ts, p_sigmask, sigsetsize));
>> +        sys_errno = errno;
>> +        if (sys_ret <= 0 || tc->ret < 0)
>> +                goto TEST_END;
>> +
>> +        cmp_ok = fds[0].revents == tc->expect_revents;
>> +        if (opt_debug) {
>> +                tst_resm(TINFO,"EXPECT: revents=0x%04x", tc->expect_revents);
>> +                tst_resm(TINFO,"RESULT: revents=0x%04x", fds[0].revents);
>> +        }
>> +
>> +TEST_END:
>> +        /*
>> +         * Check results
>> +         */
>> +        result |= (sys_errno != tc->err) || !cmp_ok;
>> +        PRINT_RESULT_CMP(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno,
>> +                         cmp_ok);
>> +
>> +        if (fd >= 0)
>> +                cleanup_file(fpath);
>> +        if (pid > 0) {
>> +                int st;
>> +                kill(pid, SIGTERM);
>> +                wait(&st);
>> +        }
>> +	return result;
>> +}
>> +
>> +
>> +/*
>> + * sighandler()
>> + */
>> +void sighandler(int sig)
>> +{
>> +        if (sig == SIGINT)
>> +                return;
>> +        // NOTREACHED
>> +        return;
>> +}
>> +
>> +
>> +/*
>> + * usage()
>> + */
>> +
>> +static void usage(const char *progname)
>> +{
>> +        tst_resm(TINFO,"usage: %s [options]", progname);
>> +        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
>> +        tst_resm(TINFO,"options:");
>> +        tst_resm(TINFO,"    -d --debug           Show debug messages");
>> +        tst_resm(TINFO,"    -h --help            Show this message");
>> +        tst_resm(TINFO,"NG");
>> +        exit(1);
>> +}
>> +
>> +
>> +/*
>> + * main()
>> + */
>> +
>> +
>> +
>> +int main(int ac, char **av) {
>> +	int result = RESULT_OK;
>> +        int c;
>> +        int i;
>> +        int lc;                 /* loop counter */
>> +        char *msg;              /* message returned from parse_opts */
>> +
>> +	struct option long_options[] = {
>> +                { "debug", no_argument, 0, 'd' },
>> +                { "help",  no_argument, 0, 'h' },
>> +                { NULL, 0, NULL, 0 }
>> +        };
>> +
>> +	progname = strchr(av[0], '/');
>> +        progname = progname ? progname + 1 : av[0];	
>> +
>> +	progdir = strdup(av[0]);
>> +        progdir = dirname(progdir);
>> +	
>> +        /* parse standard options */
>> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
>> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
>> +             tst_exit();
>> +           }
>> +
>> +        setup();
>> +
>> +        /* Check looping state if -i option given */
>> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
>> +                Tst_count = 0;
>> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
>> +			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
>> +			 while(TEST_RETURN != -1) {
>> +		                switch (c) {
>> +                		case 'd':
>> +		                        opt_debug = 1;
>> +                		        break;
>> +		                default:
>> +                		        usage(progname);
>> +                        		// NOTREACHED
>> +                		}
>> +		        }
>> +
>> +
>> +		if (ac != optind) {
>> +        	        tst_resm(TINFO,"Options are not match.");
>> +                	usage(progname);
>> +                	// NOTREACHED
>> +	        }
>> +
>> +		/*
>> +		* Execute test
>> +         	*/
>> +	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
>> +        	        int ret;
>> +	                tst_resm(TINFO,"(case%02d) START", i);
>> +	                ret = do_test(&tcase[i]);
>> +	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
>> +	                result |= ret;
>> +        	}
>> +		
>> +		/*
>> +        	 * Check results
>> +         	*/
>> +        	switch(result) {
>> +	        case RESULT_OK:
>> +        			tst_resm(TPASS, "ppoll01 call succeeded ");
>> +		                break;
>> +
>> +	        default:
>> +                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
>> +        		        RPRINTF("NG");
>> +				cleanup();
>> +				tst_exit();
>> +		                break;
>> +        	}
>> +
>> +                }
>> +        }	
>> +        cleanup();
>> +	tst_exit();
>> +}
>> +
>> --- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 12:58:57.000000000 +0530
>> +++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 13:06:52.000000000 +0530
>> @@ -706,6 +706,8 @@ pipe2_02 pipe2_02
>>
>>  poll01 poll01
>>
>> +ppoll01 ppoll01
>> +
>>  prctl01 prctl01
>>  prctl02 prctl02
>>
>>     
>
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
> is a gathering of tech-side developers & brand creativity professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, & 
> iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
> Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
>   


-- 
Michal Simek, Ing. (M.Eng)
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com p: +61-7-30090663,+42-0-721842854 f: +61-7-30090663


------------------------------------------------------------------------------
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	[flat|nested] 31+ messages in thread

* Re: [LTP] [PATCH 06/13]  Add/Port ppoll01 test for ppoll() syscall
  2009-08-06  9:56     ` Michal Simek
@ 2009-08-07 12:41       ` Subrata Modak
  2009-08-07 20:52         ` Henry Yei
  0 siblings, 1 reply; 31+ messages in thread
From: Subrata Modak @ 2009-08-07 12:41 UTC (permalink / raw)
  To: michal.simek; +Cc: LTP List, Manas Kumar Nayak

On Thu, 2009-08-06 at 11:56 +0200, Michal Simek wrote: 
> Hi,
> 
> I am getting fault on x86/Microblaze for ppoll. It is run only one
> testcase than ends.
> Have you ever met with this problem?

I have a different problem however on my x86_32 machine:

$ ./testcases/bin/ppoll01 
ppoll01     0  TINFO  :  (case00) START
open failed.
ppoll01     0  TINFO  :  (case00) END => NG
ppoll01     0  TINFO  :  (case01) START
open failed.
ppoll01     0  TINFO  :  (case01) END => NG
ppoll01     0  TINFO  :  (case02) START
open failed.
ppoll01     0  TINFO  :  (case02) END => NG
ppoll01     0  TINFO  :  (case03) START
open failed.
ppoll01     0  TINFO  :  (case03) END => NG
ppoll01     0  TINFO  :  (case04) START
open failed.
ppoll01     0  TINFO  :  (case04) END => NG
ppoll01     0  TINFO  :  (case05) START
open failed.
ppoll01     0  TINFO  :  (case05) END => NG
ppoll01     0  TINFO  :  (case06) START
open failed.
ppoll01     0  TINFO  :  (case06) END => NG
ppoll01     1  TFAIL  :  ppoll01 failed - errno = 2 : No such file or
directory
NG
$ echo $?
1

Regards--
Subrata

> 
> Thanks,
> Michal
> 
> [monstr@monstr ppoll]$ ./ppoll01
> ppoll01     0  TINFO  :  (case00) START
> EXPECT: return value(ret)=(N >= 0) errno=0 (Success), r/w check=OK
> RESULT: return value(ret)=       1 errno=0 (Success), r/w check=NG
> ppoll01     0  TINFO  :  (case00) END => NG
> ppoll01     0  TINFO  :  (case01) START
> 
> [monstr@monstr ppoll]$ echo $?
> 130
> [monstr@monstr ppoll]$
> 
> 
> > Thanks.
> >
> > Regards--
> > Subrata
> >
> > On Wed, 2009-05-27 at 15:39 +0530, Manas Kumar Nayak wrote: 
> >   
> >> diff -uprN ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/Makefile ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/Makefile
> >> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/Makefile	1970-01-01 05:30:00.000000000 +0530
> >> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/Makefile	2009-05-23 12:01:25.000000000 +0530
> >> @@ -0,0 +1,31 @@
> >> +#
> >> +#  Copyright (c) International Business Machines  Corp., 2009
> >> +#
> >> +#  This program is free software;  you can redistribute it and/or modify
> >> +#  it under the terms of the GNU General Public License as published by
> >> +#  the Free Software Foundation; either version 2 of the License, or
> >> +#  (at your option) any later version.
> >> +#
> >> +#  This program is distributed in the hope that it will be useful,
> >> +#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
> >> +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> >> +#  the GNU General Public License for more details.
> >> +#
> >> +#  You should have received a copy of the GNU General Public License
> >> +#  along with this program;  if not, write to the Free Software
> >> +#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> >> +#
> >> +
> >> +CFLAGS += -I../../../../include -Wall -O2
> >> +LDLIBS += -L../../../../lib -lltp 
> >> +
> >> +SRCS    = $(wildcard *.c)
> >> +TARGETS = $(patsubst %.c,%,$(SRCS))
> >> +
> >> +all: $(TARGETS)
> >> +
> >> +install:
> >> +	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
> >> +
> >> +clean:
> >> +	rm -f $(TARGETS)
> >> diff -uprN ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/ppoll01.c ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/ppoll01.c
> >> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/ppoll01.c	1970-01-01 05:30:00.000000000 +0530
> >> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/ppoll01.c	2009-05-27 13:00:58.000000000 +0530
> >> @@ -0,0 +1,482 @@
> >> +/******************************************************************************/
> >> +/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
> >> +/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
> >> +/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
> >> +/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
> >> +/*                                                                  	      */
> >> +/* This program is free software;  you can redistribute it and/or modify      */
> >> +/* it under the terms of the GNU General Public License as published by       */
> >> +/* the Free Software Foundation; either version 2 of the License, or          */
> >> +/* (at your option) any later version.                                        */
> >> +/*                                                                            */
> >> +/* This program is distributed in the hope that it will be useful,            */
> >> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> >> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> >> +/* the GNU General Public License for more details.                           */
> >> +/*                                                                            */
> >> +/* You should have received a copy of the GNU General Public License          */
> >> +/* along with this program;  if not, write to the Free Software               */
> >> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> >> +/*                                                                            */
> >> +/******************************************************************************/
> >> +/******************************************************************************/
> >> +/*                                                                            */
> >> +/* File:        ppoll01.c                                                     */
> >> +/*                                                                            */
> >> +/* Description: This tests the ppoll01() syscall                              */
> >> +/*									      */
> >> +/* 									      */
> >> +/*									      */
> >> +/*									      */
> >> +/*									      */
> >> +/*                                                                            */
> >> +/* Usage:  <for command-line>                                                 */
> >> +/* ppoll01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                               */
> >> +/*      where,  -c n : Run n copies concurrently.                             */
> >> +/*              -e   : Turn on errno logging.                                 */
> >> +/*              -i n : Execute test n times.                                  */
> >> +/*              -I x : Execute test for x seconds.                            */
> >> +/*              -P x : Pause for x seconds between iterations.                */
> >> +/*              -t   : Turn on syscall timing.                                */
> >> +/*                                                                            */
> >> +/* Total Tests: 1                                                             */
> >> +/*                                                                            */
> >> +/* Test Name:   ppoll01                                                       */
> >> +/* History:     Porting from Crackerjack to LTP is done by                    */
> >> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
> >> +/******************************************************************************/
> >> +#include <sys/syscall.h>
> >> +#include <sys/types.h>
> >> +#include <sys/select.h>
> >> +#include <sys/wait.h>
> >> +#include <getopt.h>
> >> +#include <string.h>
> >> +#include <stdlib.h>
> >> +#include <errno.h>
> >> +#include <stdio.h>
> >> +#include <unistd.h>
> >> +#include <fcntl.h>
> >> +#include <libgen.h>
> >> +#include <limits.h>
> >> +#include <signal.h>
> >> +#include "asm/poll.h"
> >> +
> >> +
> >> +#include "../utils/include_j_h.h"
> >> +#include "../utils/common_j_h.c"
> >> +
> >> +/* Harness Specific Include Files. */
> >> +#include "test.h"
> >> +#include "usctest.h"
> >> +#include "linux_syscall_numbers.h"
> >> +
> >> +/* Extern Global Variables */
> >> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> >> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> >> +
> >> +/* Global Variables */
> >> +char *TCID = "ppoll01";  /* Test program identifier.*/
> >> +int  testno;
> >> +int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
> >> +
> >> +/* Extern Global Functions */
> >> +/******************************************************************************/
> >> +/*                                                                            */
> >> +/* Function:    cleanup                                                       */
> >> +/*                                                                            */
> >> +/* Description: Performs all one time clean up for this test on successful    */
> >> +/*              completion,  premature exit or  failure. Closes all temporary */
> >> +/*              files, removes all temporary directories exits the test with  */
> >> +/*              appropriate return code by calling tst_exit() function.       */
> >> +/*                                                                            */
> >> +/* Input:       None.                                                         */
> >> +/*                                                                            */
> >> +/* Output:      None.                                                         */
> >> +/*                                                                            */
> >> +/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> >> +/*              On success - Exits calling tst_exit(). With '0' return code.  */
> >> +/*                                                                            */
> >> +/******************************************************************************/
> >> +extern void cleanup() {
> >> +        /* Remove tmp dir and all files in it */
> >> +        TEST_CLEANUP;
> >> +        tst_rmdir();
> >> +
> >> +        /* Exit with appropriate return code. */
> >> +        tst_exit();
> >> +}
> >> +
> >> +/* Local  Functions */
> >> +/******************************************************************************/
> >> +/*                                                                            */
> >> +/* Function:    setup                                                         */
> >> +/*                                                                            */
> >> +/* Description: Performs all one time setup for this test. This function is   */
> >> +/*              typically used to capture signals, create temporary dirs      */
> >> +/*              and temporary files that may be used in the course of this    */
> >> +/*              test.                                                         */
> >> +/*                                                                            */
> >> +/* Input:       None.                                                         */
> >> +/*                                                                            */
> >> +/* Output:      None.                                                         */
> >> +/*                                                                            */
> >> +/* Return:      On failure - Exits by calling cleanup().                      */
> >> +/*              On success - returns 0.                                       */
> >> +/*                                                                            */
> >> +/******************************************************************************/
> >> +void setup() {
> >> +        /* Capture signals if any */
> >> +        /* Create temporary directories */
> >> +        TEST_PAUSE;
> >> +        tst_tmpdir();
> >> +}
> >> +
> >> +
> >> +/*
> >> + * Macros
> >> + */
> >> +#define SYSCALL_NAME    "ppoll"
> >> +
> >> +#ifndef __NR_ppoll
> >> +#  define __NR_ppoll    309
> >> +#endif
> >> +
> >> +#ifndef POLLRDHUP
> >> +#  define POLLRDHUP     0x2000
> >> +#endif
> >> +
> >> +
> >> +/*
> >> + * Global variables
> >> + */
> >> +static int opt_debug;
> >> +static char *progname;
> >> +static char *progdir;
> >> +
> >> +enum test_type {
> >> +	NORMAL,
> >> +        MASK_SIGNAL,
> >> +        TIMEOUT,
> >> +        FD_ALREADY_CLOSED,
> >> +        SEND_SIGINT,
> >> +        INVALID_NFDS,
> >> +        INVALID_FDS,
> >> +        MINUS_NSEC,
> >> +        TOO_LARGE_NSEC,
> >> +
> >> +};
> >> +
> >> +
> >> +/*
> >> + * Data Structure
> >> + */
> >> +struct test_case {
> >> +	short expect_revents;
> >> +        int ttype;
> >> +        int ret;
> >> +        int err;
> >> +};
> >> +
> >> +
> >> +/* Test cases
> >> + *
> >> + *   test status of errors on man page
> >> + *
> >> + *   EBADF              can't check because EBADF never happen even though
> >> + *                      fd was invalid. In this case, information of invalid
> >> + *                      fd is set in revents
> >> + *   EFAULT             v ('fds' array in the invalid address space)
> >> + *   EINTR              v (a non blocked signal was caught)
> >> + *   EINVAL             v ('nfds' is over the 'RLIMIT_NOFILE' value)
> >> + *   ENOMEM             can't check because it's difficult to create no-memory
> >> + */
> >> +
> >> +
> >> +static struct test_case tcase[] = {
> >> +	{ // case00
> >> +                .ttype          = NORMAL,
> >> +                .expect_revents = POLLOUT,
> >> +                .ret            = 0,
> >> +                .err            = 0,
> >> +        },
> >> +        { // case01
> >> +                .ttype          = MASK_SIGNAL,
> >> +                .expect_revents = 0, // don't care
> >> +                .ret            = 0,
> >> +                .err            = 0,
> >> +        },
> >> +        { // case02
> >> +                .ttype          = TIMEOUT,
> >> +                .expect_revents = 0, // don't care
> >> +                .ret            = 0,
> >> +                .err            = 0,
> >> +        },
> >> +        { // case03
> >> +                .ttype          = FD_ALREADY_CLOSED,
> >> +                .expect_revents = POLLNVAL,
> >> +                .ret            = 0,
> >> +                .err            = 0,
> >> +        },
> >> +        { // case04
> >> +                .ttype          = SEND_SIGINT,
> >> +                .ret            = -1,
> >> +                .err            = EINTR,
> >> +        },
> >> +        { // case05
> >> +                .ttype          = INVALID_NFDS,
> >> +                .ret            = -1,
> >> +                .err            = EINVAL,
> >> +        },
> >> +        { // case06
> >> +                .ttype          = INVALID_FDS,
> >> +                .ret            = -1,
> >> +                .err            = EFAULT,
> >> +        },
> >> +#if 0
> >> +        { // case07
> >> +                .ttype          = MINUS_NSEC,
> >> +                .ret            = -1,
> >> +                .err            = EINVAL, // RHEL4U1 + 2.6.18 returns SUCCESS
> >> +        },
> >> +        { // case08
> >> +                .ttype          = TOO_LARGE_NSEC,
> >> +                .ret            = -1,
> >> +                .err            = EINVAL, // RHEL4U1 + 2.6.18 returns SUCCESS
> >> +        },
> >> +#endif
> >> +};
> >> +
> >> +#define NUM_TEST_FDS    1
> >> +
> >> +/*
> >> + * do_test()
> >> + *
> >> + *   Input  : TestCase Data
> >> + *   Return : RESULT_OK(0), RESULT_NG(1)
> >> + *
> >> + */
> >> +
> >> +static int do_test(struct test_case *tc)
> >> +{
> >> +        int sys_ret;
> >> +        int sys_errno;
> >> +        int result = RESULT_OK;
> >> +	int fd = -1 , cmp_ok = 1;
> >> +	char fpath[PATH_MAX];
> >> +	struct pollfd *p_fds, fds[NUM_TEST_FDS];
> >> +        unsigned int nfds = NUM_TEST_FDS;
> >> +        struct timespec *p_ts, ts;
> >> +        sigset_t *p_sigmask, sigmask;
> >> +        size_t sigsetsize = 0;
> >> +        pid_t pid = 0;
> >> +
> >> +	TEST(fd = setup_file(progdir, "test.file", fpath));
> >> +        if (fd < 0)
> >> +                return 1;
> >> +        fds[0].fd = fd;
> >> +        fds[0].events = POLLIN | POLLPRI | POLLOUT | POLLRDHUP;
> >> +        fds[0].revents = 0;
> >> +        p_fds = fds;
> >> +        p_ts = NULL;
> >> +        p_sigmask = NULL;
> >> +
> >> +	switch (tc->ttype) {
> >> +        case TIMEOUT:
> >> +                nfds = 0;
> >> +                ts.tv_sec = 0;
> >> +                ts.tv_nsec = 50000000;  // 50msec
> >> +                p_ts = &ts;
> >> +                break;
> >> +	case FD_ALREADY_CLOSED:
> >> +                TEST(close(fd));
> >> +                fd = -1;
> >> +                TEST(cleanup_file(fpath));
> >> +                break;
> >> +        case MASK_SIGNAL:
> >> +                TEST(sigemptyset(&sigmask));
> >> +                TEST(sigaddset(&sigmask, SIGINT));
> >> +                p_sigmask = &sigmask;
> >> +                //sigsetsize = sizeof(sigmask);
> >> +                sigsetsize = 8;
> >> +                nfds = 0;
> >> +                ts.tv_sec = 0;
> >> +                ts.tv_nsec = 300000000; // 300msec => need to be enough for
> >> +                                        //   waiting the signal
> >> +                p_ts = &ts;
> >> +                // fallthrough
> >> +	case SEND_SIGINT:
> >> +                nfds = 0;
> >> +                TEST(pid = create_sig_proc(100000, SIGINT)); // 100msec
> >> +                if (pid < 0)
> >> +                        return 1;
> >> +                break;
> >> +        case INVALID_NFDS:
> >> +                //nfds = RLIMIT_NOFILE + 1; ==> RHEL4U1 + 2.6.18 returns SUCCESS
> >> +                nfds = -1;
> >> +                break;
> >> +        case INVALID_FDS:
> >> +                p_fds = (void*)0xc0000000;
> >> +                break;
> >> +        case MINUS_NSEC:
> >> +                ts.tv_sec = 0;
> >> +                ts.tv_nsec = -1;
> >> +                p_ts = &ts;
> >> +                break;
> >> +	case TOO_LARGE_NSEC:
> >> +                ts.tv_sec = 0;
> >> +                ts.tv_nsec = 1000000000;
> >> +                p_ts = &ts;
> >> +                break;
> >> +        }
> >> +
> >> +	/*
> >> +	   * Execute system call
> >> +         */
> >> +        errno = 0;
> >> +        TEST(sys_ret = syscall(__NR_ppoll, p_fds, nfds, p_ts, p_sigmask, sigsetsize));
> >> +        sys_errno = errno;
> >> +        if (sys_ret <= 0 || tc->ret < 0)
> >> +                goto TEST_END;
> >> +
> >> +        cmp_ok = fds[0].revents == tc->expect_revents;
> >> +        if (opt_debug) {
> >> +                tst_resm(TINFO,"EXPECT: revents=0x%04x", tc->expect_revents);
> >> +                tst_resm(TINFO,"RESULT: revents=0x%04x", fds[0].revents);
> >> +        }
> >> +
> >> +TEST_END:
> >> +        /*
> >> +         * Check results
> >> +         */
> >> +        result |= (sys_errno != tc->err) || !cmp_ok;
> >> +        PRINT_RESULT_CMP(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno,
> >> +                         cmp_ok);
> >> +
> >> +        if (fd >= 0)
> >> +                cleanup_file(fpath);
> >> +        if (pid > 0) {
> >> +                int st;
> >> +                kill(pid, SIGTERM);
> >> +                wait(&st);
> >> +        }
> >> +	return result;
> >> +}
> >> +
> >> +
> >> +/*
> >> + * sighandler()
> >> + */
> >> +void sighandler(int sig)
> >> +{
> >> +        if (sig == SIGINT)
> >> +                return;
> >> +        // NOTREACHED
> >> +        return;
> >> +}
> >> +
> >> +
> >> +/*
> >> + * usage()
> >> + */
> >> +
> >> +static void usage(const char *progname)
> >> +{
> >> +        tst_resm(TINFO,"usage: %s [options]", progname);
> >> +        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
> >> +        tst_resm(TINFO,"options:");
> >> +        tst_resm(TINFO,"    -d --debug           Show debug messages");
> >> +        tst_resm(TINFO,"    -h --help            Show this message");
> >> +        tst_resm(TINFO,"NG");
> >> +        exit(1);
> >> +}
> >> +
> >> +
> >> +/*
> >> + * main()
> >> + */
> >> +
> >> +
> >> +
> >> +int main(int ac, char **av) {
> >> +	int result = RESULT_OK;
> >> +        int c;
> >> +        int i;
> >> +        int lc;                 /* loop counter */
> >> +        char *msg;              /* message returned from parse_opts */
> >> +
> >> +	struct option long_options[] = {
> >> +                { "debug", no_argument, 0, 'd' },
> >> +                { "help",  no_argument, 0, 'h' },
> >> +                { NULL, 0, NULL, 0 }
> >> +        };
> >> +
> >> +	progname = strchr(av[0], '/');
> >> +        progname = progname ? progname + 1 : av[0];	
> >> +
> >> +	progdir = strdup(av[0]);
> >> +        progdir = dirname(progdir);
> >> +	
> >> +        /* parse standard options */
> >> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> >> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> >> +             tst_exit();
> >> +           }
> >> +
> >> +        setup();
> >> +
> >> +        /* Check looping state if -i option given */
> >> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> >> +                Tst_count = 0;
> >> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> >> +			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
> >> +			 while(TEST_RETURN != -1) {
> >> +		                switch (c) {
> >> +                		case 'd':
> >> +		                        opt_debug = 1;
> >> +                		        break;
> >> +		                default:
> >> +                		        usage(progname);
> >> +                        		// NOTREACHED
> >> +                		}
> >> +		        }
> >> +
> >> +
> >> +		if (ac != optind) {
> >> +        	        tst_resm(TINFO,"Options are not match.");
> >> +                	usage(progname);
> >> +                	// NOTREACHED
> >> +	        }
> >> +
> >> +		/*
> >> +		* Execute test
> >> +         	*/
> >> +	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
> >> +        	        int ret;
> >> +	                tst_resm(TINFO,"(case%02d) START", i);
> >> +	                ret = do_test(&tcase[i]);
> >> +	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
> >> +	                result |= ret;
> >> +        	}
> >> +		
> >> +		/*
> >> +        	 * Check results
> >> +         	*/
> >> +        	switch(result) {
> >> +	        case RESULT_OK:
> >> +        			tst_resm(TPASS, "ppoll01 call succeeded ");
> >> +		                break;
> >> +
> >> +	        default:
> >> +                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
> >> +        		        RPRINTF("NG");
> >> +				cleanup();
> >> +				tst_exit();
> >> +		                break;
> >> +        	}
> >> +
> >> +                }
> >> +        }	
> >> +        cleanup();
> >> +	tst_exit();
> >> +}
> >> +
> >> --- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 12:58:57.000000000 +0530
> >> +++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 13:06:52.000000000 +0530
> >> @@ -706,6 +706,8 @@ pipe2_02 pipe2_02
> >>
> >>  poll01 poll01
> >>
> >> +ppoll01 ppoll01
> >> +
> >>  prctl01 prctl01
> >>  prctl02 prctl02
> >>
> >>     
> >
> >
> > ------------------------------------------------------------------------------
> > Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
> > is a gathering of tech-side developers & brand creativity professionals. Meet
> > the minds behind Google Creative Lab, Visual Complexity, Processing, & 
> > iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
> > Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
> > _______________________________________________
> > Ltp-list mailing list
> > Ltp-list@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/ltp-list
> >   
> 
> 


------------------------------------------------------------------------------
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	[flat|nested] 31+ messages in thread

* Re: [LTP] [PATCH 06/13]  Add/Port ppoll01 test for ppoll() syscall
  2009-08-07 12:41       ` Subrata Modak
@ 2009-08-07 20:52         ` Henry Yei
  0 siblings, 0 replies; 31+ messages in thread
From: Henry Yei @ 2009-08-07 20:52 UTC (permalink / raw)
  To: subrata, michal.simek; +Cc: LTP List, Manas Kumar Nayak

I see the same problem as Michal on x86 and ppc32(85xx) on kernel 2.6.28/2.6.27 respectively. 

-----Original Message-----
From: Subrata Modak [mailto:subrata@linux.vnet.ibm.com] 
Sent: Friday, August 07, 2009 5:41 AM
To: michal.simek@petalogix.com
Cc: LTP List; Manas Kumar Nayak
Subject: Re: [LTP] [PATCH 06/13] Add/Port ppoll01 test for ppoll() syscall

On Thu, 2009-08-06 at 11:56 +0200, Michal Simek wrote: 
> Hi,
> 
> I am getting fault on x86/Microblaze for ppoll. It is run only one 
> testcase than ends.
> Have you ever met with this problem?

I have a different problem however on my x86_32 machine:

$ ./testcases/bin/ppoll01 
ppoll01     0  TINFO  :  (case00) START
open failed.
ppoll01     0  TINFO  :  (case00) END => NG
ppoll01     0  TINFO  :  (case01) START
open failed.
ppoll01     0  TINFO  :  (case01) END => NG
ppoll01     0  TINFO  :  (case02) START
open failed.
ppoll01     0  TINFO  :  (case02) END => NG
ppoll01     0  TINFO  :  (case03) START
open failed.
ppoll01     0  TINFO  :  (case03) END => NG
ppoll01     0  TINFO  :  (case04) START
open failed.
ppoll01     0  TINFO  :  (case04) END => NG
ppoll01     0  TINFO  :  (case05) START
open failed.
ppoll01     0  TINFO  :  (case05) END => NG
ppoll01     0  TINFO  :  (case06) START
open failed.
ppoll01     0  TINFO  :  (case06) END => NG
ppoll01     1  TFAIL  :  ppoll01 failed - errno = 2 : No such file or
directory
NG
$ echo $?
1

Regards--
Subrata

> 
> Thanks,
> Michal
> 
> [monstr@monstr ppoll]$ ./ppoll01
> ppoll01     0  TINFO  :  (case00) START
> EXPECT: return value(ret)=(N >= 0) errno=0 (Success), r/w check=OK
> RESULT: return value(ret)=       1 errno=0 (Success), r/w check=NG
> ppoll01     0  TINFO  :  (case00) END => NG
> ppoll01     0  TINFO  :  (case01) START
> 
> [monstr@monstr ppoll]$ echo $?
> 130
> [monstr@monstr ppoll]$
> 
> 
> > Thanks.
> >
> > Regards--
> > Subrata
> >
> > On Wed, 2009-05-27 at 15:39 +0530, Manas Kumar Nayak wrote: 
> >   
> >> diff -uprN ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/Makefile ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/Makefile
> >> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/Makefile	1970-01-01 05:30:00.000000000 +0530
> >> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/Makefile	2009-05-23 12:01:25.000000000 +0530
> >> @@ -0,0 +1,31 @@
> >> +#
> >> +#  Copyright (c) International Business Machines  Corp., 2009 # #  
> >> +This program is free software;  you can redistribute it and/or 
> >> +modify #  it under the terms of the GNU General Public License as 
> >> +published by #  the Free Software Foundation; either version 2 of 
> >> +the License, or #  (at your option) any later version.
> >> +#
> >> +#  This program is distributed in the hope that it will be useful, 
> >> +#  but WITHOUT ANY WARRANTY;  without even the implied warranty of 
> >> +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See #  
> >> +the GNU General Public License for more details.
> >> +#
> >> +#  You should have received a copy of the GNU General Public 
> >> +License #  along with this program;  if not, write to the Free 
> >> +Software #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 
> >> +MA  02110-1301  USA #
> >> +
> >> +CFLAGS += -I../../../../include -Wall -O2 LDLIBS += 
> >> +-L../../../../lib -lltp
> >> +
> >> +SRCS    = $(wildcard *.c)
> >> +TARGETS = $(patsubst %.c,%,$(SRCS))
> >> +
> >> +all: $(TARGETS)
> >> +
> >> +install:
> >> +	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; 
> >> +done
> >> +
> >> +clean:
> >> +	rm -f $(TARGETS)
> >> diff -uprN ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/ppoll01.c ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/ppoll01.c
> >> --- ltp-intermediate-20090521.orig/testcases/kernel/syscalls/ppoll/ppoll01.c	1970-01-01 05:30:00.000000000 +0530
> >> +++ ltp-intermediate-20090521/testcases/kernel/syscalls/ppoll/ppoll01.c	2009-05-27 13:00:58.000000000 +0530
> >> @@ -0,0 +1,482 @@
> >> +/******************************************************************************/
> >> +/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd                */
> >> +/*          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,	      */
> >> +/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>, 	      */
> >> +/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>	      */
> >> +/*                                                                  	      */
> >> +/* This program is free software;  you can redistribute it and/or modify      */
> >> +/* it under the terms of the GNU General Public License as published by       */
> >> +/* the Free Software Foundation; either version 2 of the License, or          */
> >> +/* (at your option) any later version.                                        */
> >> +/*                                                                            */
> >> +/* This program is distributed in the hope that it will be useful,            */
> >> +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> >> +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> >> +/* the GNU General Public License for more details.                           */
> >> +/*                                                                            */
> >> +/* You should have received a copy of the GNU General Public License          */
> >> +/* along with this program;  if not, write to the Free Software               */
> >> +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
> >> +/*                                                                            */
> >> +/*****************************************************************
> >> +*************/ 
> >> +/******************************************************************************/
> >> +/*                                                                            */
> >> +/* File:        ppoll01.c                                                     */
> >> +/*                                                                            */
> >> +/* Description: This tests the ppoll01() syscall                              */
> >> +/*									      */
> >> +/* 									      */
> >> +/*									      */
> >> +/*									      */
> >> +/*									      */
> >> +/*                                                                            */
> >> +/* Usage:  <for command-line>                                                 */
> >> +/* ppoll01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                               */
> >> +/*      where,  -c n : Run n copies concurrently.                             */
> >> +/*              -e   : Turn on errno logging.                                 */
> >> +/*              -i n : Execute test n times.                                  */
> >> +/*              -I x : Execute test for x seconds.                            */
> >> +/*              -P x : Pause for x seconds between iterations.                */
> >> +/*              -t   : Turn on syscall timing.                                */
> >> +/*                                                                            */
> >> +/* Total Tests: 1                                                             */
> >> +/*                                                                            */
> >> +/* Test Name:   ppoll01                                                       */
> >> +/* History:     Porting from Crackerjack to LTP is done by                    */
> >> +/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
> >> +/*****************************************************************
> >> +*************/
> >> +#include <sys/syscall.h>
> >> +#include <sys/types.h>
> >> +#include <sys/select.h>
> >> +#include <sys/wait.h>
> >> +#include <getopt.h>
> >> +#include <string.h>
> >> +#include <stdlib.h>
> >> +#include <errno.h>
> >> +#include <stdio.h>
> >> +#include <unistd.h>
> >> +#include <fcntl.h>
> >> +#include <libgen.h>
> >> +#include <limits.h>
> >> +#include <signal.h>
> >> +#include "asm/poll.h"
> >> +
> >> +
> >> +#include "../utils/include_j_h.h"
> >> +#include "../utils/common_j_h.c"
> >> +
> >> +/* Harness Specific Include Files. */ #include "test.h"
> >> +#include "usctest.h"
> >> +#include "linux_syscall_numbers.h"
> >> +
> >> +/* Extern Global Variables */
> >> +extern int Tst_count;           /* counter for tst_xxx routines.         */
> >> +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir() */
> >> +
> >> +/* Global Variables */
> >> +char *TCID = "ppoll01";  /* Test program identifier.*/ int  
> >> +testno;
> >> +int  TST_TOTAL = 1;                   /* total number of tests in this file.   */
> >> +
> >> +/* Extern Global Functions */
> >> +/******************************************************************************/
> >> +/*                                                                            */
> >> +/* Function:    cleanup                                                       */
> >> +/*                                                                            */
> >> +/* Description: Performs all one time clean up for this test on successful    */
> >> +/*              completion,  premature exit or  failure. Closes all temporary */
> >> +/*              files, removes all temporary directories exits the test with  */
> >> +/*              appropriate return code by calling tst_exit() function.       */
> >> +/*                                                                            */
> >> +/* Input:       None.                                                         */
> >> +/*                                                                            */
> >> +/* Output:      None.                                                         */
> >> +/*                                                                            */
> >> +/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
> >> +/*              On success - Exits calling tst_exit(). With '0' return code.  */
> >> +/*                                                                            */
> >> +/*****************************************************************
> >> +*************/
> >> +extern void cleanup() {
> >> +        /* Remove tmp dir and all files in it */
> >> +        TEST_CLEANUP;
> >> +        tst_rmdir();
> >> +
> >> +        /* Exit with appropriate return code. */
> >> +        tst_exit();
> >> +}
> >> +
> >> +/* Local  Functions */
> >> +/******************************************************************************/
> >> +/*                                                                            */
> >> +/* Function:    setup                                                         */
> >> +/*                                                                            */
> >> +/* Description: Performs all one time setup for this test. This function is   */
> >> +/*              typically used to capture signals, create temporary dirs      */
> >> +/*              and temporary files that may be used in the course of this    */
> >> +/*              test.                                                         */
> >> +/*                                                                            */
> >> +/* Input:       None.                                                         */
> >> +/*                                                                            */
> >> +/* Output:      None.                                                         */
> >> +/*                                                                            */
> >> +/* Return:      On failure - Exits by calling cleanup().                      */
> >> +/*              On success - returns 0.                                       */
> >> +/*                                                                            */
> >> +/*****************************************************************
> >> +*************/
> >> +void setup() {
> >> +        /* Capture signals if any */
> >> +        /* Create temporary directories */
> >> +        TEST_PAUSE;
> >> +        tst_tmpdir();
> >> +}
> >> +
> >> +
> >> +/*
> >> + * Macros
> >> + */
> >> +#define SYSCALL_NAME    "ppoll"
> >> +
> >> +#ifndef __NR_ppoll
> >> +#  define __NR_ppoll    309
> >> +#endif
> >> +
> >> +#ifndef POLLRDHUP
> >> +#  define POLLRDHUP     0x2000
> >> +#endif
> >> +
> >> +
> >> +/*
> >> + * Global variables
> >> + */
> >> +static int opt_debug;
> >> +static char *progname;
> >> +static char *progdir;
> >> +
> >> +enum test_type {
> >> +	NORMAL,
> >> +        MASK_SIGNAL,
> >> +        TIMEOUT,
> >> +        FD_ALREADY_CLOSED,
> >> +        SEND_SIGINT,
> >> +        INVALID_NFDS,
> >> +        INVALID_FDS,
> >> +        MINUS_NSEC,
> >> +        TOO_LARGE_NSEC,
> >> +
> >> +};
> >> +
> >> +
> >> +/*
> >> + * Data Structure
> >> + */
> >> +struct test_case {
> >> +	short expect_revents;
> >> +        int ttype;
> >> +        int ret;
> >> +        int err;
> >> +};
> >> +
> >> +
> >> +/* Test cases
> >> + *
> >> + *   test status of errors on man page
> >> + *
> >> + *   EBADF              can't check because EBADF never happen even though
> >> + *                      fd was invalid. In this case, information of invalid
> >> + *                      fd is set in revents
> >> + *   EFAULT             v ('fds' array in the invalid address space)
> >> + *   EINTR              v (a non blocked signal was caught)
> >> + *   EINVAL             v ('nfds' is over the 'RLIMIT_NOFILE' value)
> >> + *   ENOMEM             can't check because it's difficult to create no-memory
> >> + */
> >> +
> >> +
> >> +static struct test_case tcase[] = {
> >> +	{ // case00
> >> +                .ttype          = NORMAL,
> >> +                .expect_revents = POLLOUT,
> >> +                .ret            = 0,
> >> +                .err            = 0,
> >> +        },
> >> +        { // case01
> >> +                .ttype          = MASK_SIGNAL,
> >> +                .expect_revents = 0, // don't care
> >> +                .ret            = 0,
> >> +                .err            = 0,
> >> +        },
> >> +        { // case02
> >> +                .ttype          = TIMEOUT,
> >> +                .expect_revents = 0, // don't care
> >> +                .ret            = 0,
> >> +                .err            = 0,
> >> +        },
> >> +        { // case03
> >> +                .ttype          = FD_ALREADY_CLOSED,
> >> +                .expect_revents = POLLNVAL,
> >> +                .ret            = 0,
> >> +                .err            = 0,
> >> +        },
> >> +        { // case04
> >> +                .ttype          = SEND_SIGINT,
> >> +                .ret            = -1,
> >> +                .err            = EINTR,
> >> +        },
> >> +        { // case05
> >> +                .ttype          = INVALID_NFDS,
> >> +                .ret            = -1,
> >> +                .err            = EINVAL,
> >> +        },
> >> +        { // case06
> >> +                .ttype          = INVALID_FDS,
> >> +                .ret            = -1,
> >> +                .err            = EFAULT,
> >> +        },
> >> +#if 0
> >> +        { // case07
> >> +                .ttype          = MINUS_NSEC,
> >> +                .ret            = -1,
> >> +                .err            = EINVAL, // RHEL4U1 + 2.6.18 returns SUCCESS
> >> +        },
> >> +        { // case08
> >> +                .ttype          = TOO_LARGE_NSEC,
> >> +                .ret            = -1,
> >> +                .err            = EINVAL, // RHEL4U1 + 2.6.18 returns SUCCESS
> >> +        },
> >> +#endif
> >> +};
> >> +
> >> +#define NUM_TEST_FDS    1
> >> +
> >> +/*
> >> + * do_test()
> >> + *
> >> + *   Input  : TestCase Data
> >> + *   Return : RESULT_OK(0), RESULT_NG(1)
> >> + *
> >> + */
> >> +
> >> +static int do_test(struct test_case *tc) {
> >> +        int sys_ret;
> >> +        int sys_errno;
> >> +        int result = RESULT_OK;
> >> +	int fd = -1 , cmp_ok = 1;
> >> +	char fpath[PATH_MAX];
> >> +	struct pollfd *p_fds, fds[NUM_TEST_FDS];
> >> +        unsigned int nfds = NUM_TEST_FDS;
> >> +        struct timespec *p_ts, ts;
> >> +        sigset_t *p_sigmask, sigmask;
> >> +        size_t sigsetsize = 0;
> >> +        pid_t pid = 0;
> >> +
> >> +	TEST(fd = setup_file(progdir, "test.file", fpath));
> >> +        if (fd < 0)
> >> +                return 1;
> >> +        fds[0].fd = fd;
> >> +        fds[0].events = POLLIN | POLLPRI | POLLOUT | POLLRDHUP;
> >> +        fds[0].revents = 0;
> >> +        p_fds = fds;
> >> +        p_ts = NULL;
> >> +        p_sigmask = NULL;
> >> +
> >> +	switch (tc->ttype) {
> >> +        case TIMEOUT:
> >> +                nfds = 0;
> >> +                ts.tv_sec = 0;
> >> +                ts.tv_nsec = 50000000;  // 50msec
> >> +                p_ts = &ts;
> >> +                break;
> >> +	case FD_ALREADY_CLOSED:
> >> +                TEST(close(fd));
> >> +                fd = -1;
> >> +                TEST(cleanup_file(fpath));
> >> +                break;
> >> +        case MASK_SIGNAL:
> >> +                TEST(sigemptyset(&sigmask));
> >> +                TEST(sigaddset(&sigmask, SIGINT));
> >> +                p_sigmask = &sigmask;
> >> +                //sigsetsize = sizeof(sigmask);
> >> +                sigsetsize = 8;
> >> +                nfds = 0;
> >> +                ts.tv_sec = 0;
> >> +                ts.tv_nsec = 300000000; // 300msec => need to be enough for
> >> +                                        //   waiting the signal
> >> +                p_ts = &ts;
> >> +                // fallthrough
> >> +	case SEND_SIGINT:
> >> +                nfds = 0;
> >> +                TEST(pid = create_sig_proc(100000, SIGINT)); // 100msec
> >> +                if (pid < 0)
> >> +                        return 1;
> >> +                break;
> >> +        case INVALID_NFDS:
> >> +                //nfds = RLIMIT_NOFILE + 1; ==> RHEL4U1 + 2.6.18 returns SUCCESS
> >> +                nfds = -1;
> >> +                break;
> >> +        case INVALID_FDS:
> >> +                p_fds = (void*)0xc0000000;
> >> +                break;
> >> +        case MINUS_NSEC:
> >> +                ts.tv_sec = 0;
> >> +                ts.tv_nsec = -1;
> >> +                p_ts = &ts;
> >> +                break;
> >> +	case TOO_LARGE_NSEC:
> >> +                ts.tv_sec = 0;
> >> +                ts.tv_nsec = 1000000000;
> >> +                p_ts = &ts;
> >> +                break;
> >> +        }
> >> +
> >> +	/*
> >> +	   * Execute system call
> >> +         */
> >> +        errno = 0;
> >> +        TEST(sys_ret = syscall(__NR_ppoll, p_fds, nfds, p_ts, p_sigmask, sigsetsize));
> >> +        sys_errno = errno;
> >> +        if (sys_ret <= 0 || tc->ret < 0)
> >> +                goto TEST_END;
> >> +
> >> +        cmp_ok = fds[0].revents == tc->expect_revents;
> >> +        if (opt_debug) {
> >> +                tst_resm(TINFO,"EXPECT: revents=0x%04x", tc->expect_revents);
> >> +                tst_resm(TINFO,"RESULT: revents=0x%04x", fds[0].revents);
> >> +        }
> >> +
> >> +TEST_END:
> >> +        /*
> >> +         * Check results
> >> +         */
> >> +        result |= (sys_errno != tc->err) || !cmp_ok;
> >> +        PRINT_RESULT_CMP(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno,
> >> +                         cmp_ok);
> >> +
> >> +        if (fd >= 0)
> >> +                cleanup_file(fpath);
> >> +        if (pid > 0) {
> >> +                int st;
> >> +                kill(pid, SIGTERM);
> >> +                wait(&st);
> >> +        }
> >> +	return result;
> >> +}
> >> +
> >> +
> >> +/*
> >> + * sighandler()
> >> + */
> >> +void sighandler(int sig)
> >> +{
> >> +        if (sig == SIGINT)
> >> +                return;
> >> +        // NOTREACHED
> >> +        return;
> >> +}
> >> +
> >> +
> >> +/*
> >> + * usage()
> >> + */
> >> +
> >> +static void usage(const char *progname) {
> >> +        tst_resm(TINFO,"usage: %s [options]", progname);
> >> +        tst_resm(TINFO,"This is a regression test program of %s system call.",SYSCALL_NAME);
> >> +        tst_resm(TINFO,"options:");
> >> +        tst_resm(TINFO,"    -d --debug           Show debug messages");
> >> +        tst_resm(TINFO,"    -h --help            Show this message");
> >> +        tst_resm(TINFO,"NG");
> >> +        exit(1);
> >> +}
> >> +
> >> +
> >> +/*
> >> + * main()
> >> + */
> >> +
> >> +
> >> +
> >> +int main(int ac, char **av) {
> >> +	int result = RESULT_OK;
> >> +        int c;
> >> +        int i;
> >> +        int lc;                 /* loop counter */
> >> +        char *msg;              /* message returned from parse_opts */
> >> +
> >> +	struct option long_options[] = {
> >> +                { "debug", no_argument, 0, 'd' },
> >> +                { "help",  no_argument, 0, 'h' },
> >> +                { NULL, 0, NULL, 0 }
> >> +        };
> >> +
> >> +	progname = strchr(av[0], '/');
> >> +        progname = progname ? progname + 1 : av[0];	
> >> +
> >> +	progdir = strdup(av[0]);
> >> +        progdir = dirname(progdir);
> >> +	
> >> +        /* parse standard options */
> >> +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
> >> +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> >> +             tst_exit();
> >> +           }
> >> +
> >> +        setup();
> >> +
> >> +        /* Check looping state if -i option given */
> >> +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> >> +                Tst_count = 0;
> >> +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> >> +			 TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
> >> +			 while(TEST_RETURN != -1) {
> >> +		                switch (c) {
> >> +                		case 'd':
> >> +		                        opt_debug = 1;
> >> +                		        break;
> >> +		                default:
> >> +                		        usage(progname);
> >> +                        		// NOTREACHED
> >> +                		}
> >> +		        }
> >> +
> >> +
> >> +		if (ac != optind) {
> >> +        	        tst_resm(TINFO,"Options are not match.");
> >> +                	usage(progname);
> >> +                	// NOTREACHED
> >> +	        }
> >> +
> >> +		/*
> >> +		* Execute test
> >> +         	*/
> >> +	        for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0])); i++) {
> >> +        	        int ret;
> >> +	                tst_resm(TINFO,"(case%02d) START", i);
> >> +	                ret = do_test(&tcase[i]);
> >> +	                tst_resm(TINFO,"(case%02d) END => %s", i, (ret == 0) ? "OK" : "NG");
> >> +	                result |= ret;
> >> +        	}
> >> +		
> >> +		/*
> >> +        	 * Check results
> >> +         	*/
> >> +        	switch(result) {
> >> +	        case RESULT_OK:
> >> +        			tst_resm(TPASS, "ppoll01 call succeeded ");
> >> +		                break;
> >> +
> >> +	        default:
> >> +                 	   	tst_resm(TFAIL, "%s failed - errno = %d : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));
> >> +        		        RPRINTF("NG");
> >> +				cleanup();
> >> +				tst_exit();
> >> +		                break;
> >> +        	}
> >> +
> >> +                }
> >> +        }	
> >> +        cleanup();
> >> +	tst_exit();
> >> +}
> >> +
> >> --- ltp-intermediate-20090521.orig/runtest/syscalls	2009-05-27 12:58:57.000000000 +0530
> >> +++ ltp-intermediate-20090521/runtest/syscalls	2009-05-27 13:06:52.000000000 +0530
> >> @@ -706,6 +706,8 @@ pipe2_02 pipe2_02
> >>
> >>  poll01 poll01
> >>
> >> +ppoll01 ppoll01
> >> +
> >>  prctl01 prctl01
> >>  prctl02 prctl02
> >>
> >>     
> >
> >
> > --------------------------------------------------------------------
> > ---------- Register Now for Creativity and Technology (CaT), June 
> > 3rd, NYC. CaT is a gathering of tech-side developers & brand 
> > creativity professionals. Meet the minds behind Google Creative Lab, 
> > Visual Complexity, Processing, & iPhoneDevCamp as they present 
> > alongside digital heavyweights like Barbarian Group, R/GA, & Big 
> > Spaceship. http://p.sf.net/sfu/creativitycat-com
> > _______________________________________________
> > Ltp-list mailing list
> > Ltp-list@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/ltp-list
> >   
> 
> 


------------------------------------------------------------------------------
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

------------------------------------------------------------------------------
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	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2009-08-07 20:53 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-27 10:06 [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Manas Kumar Nayak
2009-05-27 10:07 ` [LTP] [PATCH 01/13] Add/Port Utility Headers for these set of tests Manas Kumar Nayak
2009-05-29 12:55   ` Subrata Modak
2009-05-27 10:07 ` [LTP] [PATCH 02/13] Add/Port get_mempolicy01 test for get_mempolicy() syscall Manas Kumar Nayak
2009-05-29 12:55   ` Subrata Modak
2009-05-27 10:08 ` [LTP] [PATCH 03/13] Add/Port clock_getres01 test for clock_getres() syscall Manas Kumar Nayak
2009-05-29 12:56   ` Subrata Modak
2009-05-27 10:08 ` [LTP] [PATCH 04/13] Add/Port clock_nanosleep01 test for clock_nanosleep() syscall Manas Kumar Nayak
2009-05-29 12:56   ` Subrata Modak
2009-05-27 10:09 ` [LTP] [PATCH 05/13] Add/Port mq_notify01 test for mq_notify() syscall Manas Kumar Nayak
2009-05-29 12:56   ` Subrata Modak
2009-05-27 10:09 ` [LTP] [PATCH 06/13] Add/Port ppoll01 test for ppoll() syscall Manas Kumar Nayak
2009-05-29 12:56   ` Subrata Modak
2009-08-06  9:56     ` Michal Simek
2009-08-07 12:41       ` Subrata Modak
2009-08-07 20:52         ` Henry Yei
2009-05-27 10:10 ` [LTP] [PATCH 07/13] Add/Port mq_open01 test for mq_open() syscall Manas Kumar Nayak
2009-05-29 12:56   ` Subrata Modak
2009-05-27 10:10 ` [LTP] [PATCH 08/13] Add/Port mq_timedreceive01 test for mq_timedreceive() syscall Manas Kumar Nayak
2009-05-29 12:56   ` Subrata Modak
2009-05-27 10:11 ` [LTP] [PATCH 09/13] Add/Port utimes01 test for utimes() syscall Manas Kumar Nayak
2009-05-29 12:56   ` Subrata Modak
2009-05-27 10:11 ` [LTP] [PATCH 10/13] Add/Port mq_unlink01 test for mq_unlink() syscall Manas Kumar Nayak
2009-05-29 12:56   ` Subrata Modak
2009-05-27 10:12 ` [LTP] [PATCH 11/13] Add/Port mq_timedsend01 test for mq_timedsend() syscall Manas Kumar Nayak
2009-05-29 12:57   ` Subrata Modak
2009-05-27 10:12 ` [LTP] [PATCH 12/13] Add/Port unshare01 test for unshare() syscall Manas Kumar Nayak
2009-05-29 12:57   ` Subrata Modak
2009-05-27 10:13 ` [LTP] [PATCH 13/13] Add/Port unshare02 " Manas Kumar Nayak
2009-05-29 12:57   ` Subrata Modak
2009-05-29 12:55 ` [LTP] [PATCH 00/13][2nd Bunch] Port Crackerjack Syscall tests(missing) to LTP Subrata Modak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox