* [LTP] [PATCH] mq_notify/mq_notify02.c: add new error tests
@ 2014-02-21 8:33 Zeng Linggang
2014-03-18 16:58 ` chrubis
0 siblings, 1 reply; 2+ messages in thread
From: Zeng Linggang @ 2014-02-21 8:33 UTC (permalink / raw)
To: ltp-list
Add EINVAL error tests for mq_notify(2).
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/.gitignore | 1 +
testcases/kernel/syscalls/mq_notify/mq_notify02.c | 97 +++++++++++++++++++++++
3 files changed, 99 insertions(+)
create mode 100644 testcases/kernel/syscalls/mq_notify/mq_notify02.c
diff --git a/runtest/syscalls b/runtest/syscalls
index aec49ad..dcfceeb 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -608,6 +608,7 @@ mprotect02 mprotect02
mprotect03 mprotect03
mq_notify01 mq_notify01
+mq_notify02 mq_notify02
mq_open01 mq_open01
mq_timedreceive01 mq_timedreceive01
mq_timedsend01 mq_timedsend01
diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore
index d461569..c9552c6 100644
--- a/testcases/kernel/syscalls/.gitignore
+++ b/testcases/kernel/syscalls/.gitignore
@@ -550,6 +550,7 @@
/mprotect/mprotect02
/mprotect/mprotect03
/mq_notify/mq_notify01
+/mq_notify/mq_notify02
/mq_open/mq_open01
/mq_timedreceive/mq_timedreceive01
/mq_timedsend/mq_timedsend01
diff --git a/testcases/kernel/syscalls/mq_notify/mq_notify02.c b/testcases/kernel/syscalls/mq_notify/mq_notify02.c
new file mode 100644
index 0000000..46ae3e3
--- /dev/null
+++ b/testcases/kernel/syscalls/mq_notify/mq_notify02.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2014 Fujitsu Ltd.
+ * Author: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program.
+ */
+/*
+ * ALGORITHM
+ * test 1:
+ * sevp->sigev_notify = -1, EINVAL should be returned.
+ * test 2:
+ * sevp->sigev_notify = SIGEV_SIGNAL and sevp->sigev_signo > _NSG,
+ * EINVAL should be returned.
+ */
+
+#include <errno.h>
+#include <mqueue.h>
+#include "test.h"
+#include "usctest.h"
+
+char *TCID = "mq_notify02";
+static void setup(void);
+static void cleanup(void);
+
+static struct test_case_t {
+ struct sigevent sevp;
+ int exp_errno;
+} test_cases[] = {
+ {{.sigev_notify = -1}, EINVAL},
+ {{.sigev_notify = SIGEV_SIGNAL, .sigev_signo = _NSIG+1}, EINVAL},
+};
+
+int TST_TOTAL = ARRAY_SIZE(test_cases);
+static void mq_notify_verify(struct test_case_t *);
+static int exp_enos[] = { EINVAL, 0 };
+
+int main(int argc, char **argv)
+{
+ int lc;
+ int i;
+ char *msg;
+
+ msg = parse_opts(argc, argv, NULL, NULL);
+ if (msg != NULL)
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+ setup();
+
+ TEST_EXP_ENOS(exp_enos);
+
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+ tst_count = 0;
+ for (i = 0; i < TST_TOTAL; i++)
+ mq_notify_verify(&test_cases[i]);
+ }
+ cleanup();
+ tst_exit();
+}
+
+static void setup(void)
+{
+ tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+ TEST_PAUSE;
+}
+
+static void mq_notify_verify(struct test_case_t *test)
+{
+ TEST(mq_notify(0, &(test->sevp)));
+
+ if (TEST_RETURN != -1) {
+ tst_resm(TFAIL, "mq_notify() succeeded unexpectedly");
+ return;
+ }
+
+ if (TEST_ERRNO == test->exp_errno) {
+ tst_resm(TPASS | TTERRNO, "mq_notify failed as expected");
+ } else {
+ tst_resm(TFAIL | TTERRNO,
+ "mq_notify failed unexpectedly; expected: %d - %s",
+ test->exp_errno, strerror(test->exp_errno));
+ }
+}
+
+static void cleanup(void)
+{
+ TEST_CLEANUP;
+}
--
1.8.4.2
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH] mq_notify/mq_notify02.c: add new error tests
2014-02-21 8:33 [LTP] [PATCH] mq_notify/mq_notify02.c: add new error tests Zeng Linggang
@ 2014-03-18 16:58 ` chrubis
0 siblings, 0 replies; 2+ messages in thread
From: chrubis @ 2014-03-18 16:58 UTC (permalink / raw)
To: Zeng Linggang; +Cc: ltp-list
Hi!
> Add EINVAL error tests for mq_notify(2).
>
> Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-03-18 16:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-21 8:33 [LTP] [PATCH] mq_notify/mq_notify02.c: add new error tests Zeng Linggang
2014-03-18 16:58 ` chrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox