Mon Apr 25 20:55:07 2011 UTC ()
In nice_err testcase, use ATF_REQUIRE_ERRNO.


(njoly)
diff -r1.5 -r1.6 src/tests/lib/libc/gen/t_nice.c

cvs diff -r1.5 -r1.6 src/tests/lib/libc/gen/t_nice.c (expand / switch to unified diff)

--- src/tests/lib/libc/gen/t_nice.c 2011/04/17 06:18:23 1.5
+++ src/tests/lib/libc/gen/t_nice.c 2011/04/25 20:55:06 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_nice.c,v 1.5 2011/04/17 06:18:23 jruoho Exp $ */ 1/* $NetBSD: t_nice.c,v 1.6 2011/04/25 20:55:06 njoly Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2011 The NetBSD Foundation, Inc. 4 * Copyright (c) 2011 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jukka Ruohonen. 8 * by Jukka Ruohonen.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31#include <sys/cdefs.h> 31#include <sys/cdefs.h>
32__RCSID("$NetBSD: t_nice.c,v 1.5 2011/04/17 06:18:23 jruoho Exp $"); 32__RCSID("$NetBSD: t_nice.c,v 1.6 2011/04/25 20:55:06 njoly Exp $");
33 33
34#include <sys/resource.h> 34#include <sys/resource.h>
35#include <sys/wait.h> 35#include <sys/wait.h>
36 36
37#include <atf-c.h> 37#include <atf-c.h>
38#include <errno.h> 38#include <errno.h>
39#include <limits.h> 39#include <limits.h>
40#include <pthread.h> 40#include <pthread.h>
41#include <stdlib.h> 41#include <stdlib.h>
42#include <unistd.h> 42#include <unistd.h>
43 43
44static void *threadfunc(void *); 44static void *threadfunc(void *);
45 45
@@ -73,30 +73,27 @@ ATF_TC_BODY(nice_err, tc) @@ -73,30 +73,27 @@ ATF_TC_BODY(nice_err, tc)
73 73
74 /* 74 /*
75 * The call should fail with EPERM if the 75 * The call should fail with EPERM if the
76 * supplied parameter is negative and the 76 * supplied parameter is negative and the
77 * caller does not have privileges. Note 77 * caller does not have privileges. Note
78 * that the errno is thus "wrong" in NetBSD. 78 * that the errno is thus "wrong" in NetBSD.
79 */ 79 */
80 atf_tc_expect_fail("PR lib/42587"); 80 atf_tc_expect_fail("PR lib/42587");
81 81
82 for (i = -20; i < 0; i++) { 82 for (i = -20; i < 0; i++) {
83 83
84 errno = 0; 84 errno = 0;
85 85
86 ATF_REQUIRE(nice(i) == -1); 86 ATF_REQUIRE_ERRNO(EPERM, nice(i) == -1);
87 
88 if (errno != EPERM) 
89 atf_tc_fail("wrong errno"); 
90 } 87 }
91} 88}
92 89
93ATF_TC(nice_priority); 90ATF_TC(nice_priority);
94ATF_TC_HEAD(nice_priority, tc) 91ATF_TC_HEAD(nice_priority, tc)
95{ 92{
96 atf_tc_set_md_var(tc, "descr", "Test nice(3) vs. getpriority(2)"); 93 atf_tc_set_md_var(tc, "descr", "Test nice(3) vs. getpriority(2)");
97} 94}
98 95
99ATF_TC_BODY(nice_priority, tc) 96ATF_TC_BODY(nice_priority, tc)
100{ 97{
101 int i, pri, nic; 98 int i, pri, nic;
102 pid_t pid; 99 pid_t pid;