xref: /netbsd-src/tests/lib/libc/gen/execve/t_execve.c (revision 200d779b75dbeafa7bc01fd0f60bc61185f6967b)
1*200d779bSchristos /*	$NetBSD: t_execve.c,v 1.2 2015/09/12 15:21:33 christos Exp $	*/
2413d532bSuebayasi 
3413d532bSuebayasi /*-
4413d532bSuebayasi  * Copyright (c) 2014 The NetBSD Foundation, Inc.
5413d532bSuebayasi  * All rights reserved.
6413d532bSuebayasi  *
7413d532bSuebayasi  * Redistribution and use in source and binary forms, with or without
8413d532bSuebayasi  * modification, are permitted provided that the following conditions
9413d532bSuebayasi  * are met:
10413d532bSuebayasi  * 1. Redistributions of source code must retain the above copyright
11413d532bSuebayasi  *    notice, this list of conditions and the following disclaimer.
12413d532bSuebayasi  * 2. Redistributions in binary form must reproduce the above copyright
13413d532bSuebayasi  *    notice, this list of conditions and the following disclaimer in the
14413d532bSuebayasi  *    documentation and/or other materials provided with the distribution.
15413d532bSuebayasi  *
16413d532bSuebayasi  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17413d532bSuebayasi  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18413d532bSuebayasi  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19413d532bSuebayasi  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20413d532bSuebayasi  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21413d532bSuebayasi  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22413d532bSuebayasi  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23413d532bSuebayasi  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24413d532bSuebayasi  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25413d532bSuebayasi  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26413d532bSuebayasi  * POSSIBILITY OF SUCH DAMAGE.
27413d532bSuebayasi  */
28413d532bSuebayasi 
29413d532bSuebayasi #include <atf-c.h>
30413d532bSuebayasi 
31413d532bSuebayasi #include <errno.h>
32413d532bSuebayasi #include <stddef.h>
33413d532bSuebayasi #include <stdio.h>
34413d532bSuebayasi #include <unistd.h>
35413d532bSuebayasi 
36413d532bSuebayasi ATF_TC(t_execve_null);
37413d532bSuebayasi 
ATF_TC_HEAD(t_execve_null,tc)38413d532bSuebayasi ATF_TC_HEAD(t_execve_null, tc)
39413d532bSuebayasi {
40413d532bSuebayasi 	atf_tc_set_md_var(tc, "descr",
41413d532bSuebayasi 	    "Tests an empty execve(2) executing");
42413d532bSuebayasi }
43413d532bSuebayasi 
ATF_TC_BODY(t_execve_null,tc)44413d532bSuebayasi ATF_TC_BODY(t_execve_null, tc)
45413d532bSuebayasi {
46413d532bSuebayasi 	int err;
47413d532bSuebayasi 
48413d532bSuebayasi 	err = execve(NULL, NULL, NULL);
49413d532bSuebayasi 	ATF_REQUIRE(err == -1);
50*200d779bSchristos 	ATF_REQUIRE_MSG(errno == EFAULT,
51*200d779bSchristos 	    "wrong error returned %d instead of %d", errno, EFAULT);
52413d532bSuebayasi }
53413d532bSuebayasi 
ATF_TP_ADD_TCS(tp)54413d532bSuebayasi ATF_TP_ADD_TCS(tp)
55413d532bSuebayasi {
56413d532bSuebayasi 	ATF_TP_ADD_TC(tp, t_execve_null);
57413d532bSuebayasi 
58413d532bSuebayasi 	return atf_no_error();
59413d532bSuebayasi }
60