xref: /minix3/tests/dev/scsipi/t_cd.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /*	$NetBSD: t_cd.c,v 1.7 2014/04/25 00:24:39 pooka Exp $	*/
211be35a1SLionel Sambuc 
311be35a1SLionel Sambuc /*
411be35a1SLionel Sambuc  * Copyright (c) 2010 Antti Kantee.  All Rights Reserved.
511be35a1SLionel Sambuc  *
611be35a1SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
711be35a1SLionel Sambuc  * modification, are permitted provided that the following conditions
811be35a1SLionel Sambuc  * are met:
911be35a1SLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
1011be35a1SLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
1111be35a1SLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
1211be35a1SLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
1311be35a1SLionel Sambuc  *    documentation and/or other materials provided with the distribution.
1411be35a1SLionel Sambuc  *
1511be35a1SLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
1611be35a1SLionel Sambuc  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1711be35a1SLionel Sambuc  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1811be35a1SLionel Sambuc  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1911be35a1SLionel Sambuc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2011be35a1SLionel Sambuc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2111be35a1SLionel Sambuc  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2211be35a1SLionel Sambuc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2311be35a1SLionel Sambuc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2411be35a1SLionel Sambuc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2511be35a1SLionel Sambuc  * SUCH DAMAGE.
2611be35a1SLionel Sambuc  */
2711be35a1SLionel Sambuc 
2811be35a1SLionel Sambuc #include <sys/types.h>
2911be35a1SLionel Sambuc #include <sys/ioctl.h>
3011be35a1SLionel Sambuc 
3111be35a1SLionel Sambuc #include <atf-c.h>
3211be35a1SLionel Sambuc #include <fcntl.h>
3311be35a1SLionel Sambuc #include <signal.h>
3411be35a1SLionel Sambuc #include <stdio.h>
3511be35a1SLionel Sambuc #include <util.h>
3611be35a1SLionel Sambuc 
3711be35a1SLionel Sambuc #include <rump/rump.h>
3811be35a1SLionel Sambuc #include <rump/rump_syscalls.h>
39*0a6a1f1dSLionel Sambuc 
40*0a6a1f1dSLionel Sambuc #include "scsitest.h"
4111be35a1SLionel Sambuc 
4211be35a1SLionel Sambuc #include "../../h_macros.h"
4311be35a1SLionel Sambuc 
4411be35a1SLionel Sambuc ATF_TC(noisyeject);
ATF_TC_HEAD(noisyeject,tc)4511be35a1SLionel Sambuc ATF_TC_HEAD(noisyeject, tc)
4611be35a1SLionel Sambuc {
4711be35a1SLionel Sambuc 
4811be35a1SLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "test for CD eject noisyness "
4911be35a1SLionel Sambuc 	    "(PR kern/43785)");
5011be35a1SLionel Sambuc }
5111be35a1SLionel Sambuc 
ATF_TC_BODY(noisyeject,tc)5211be35a1SLionel Sambuc ATF_TC_BODY(noisyeject, tc)
5311be35a1SLionel Sambuc {
5411be35a1SLionel Sambuc 	static char fname[] = "/dev/rcd0_";
5511be35a1SLionel Sambuc 	int part, fd, arg = 0;
5611be35a1SLionel Sambuc 
5711be35a1SLionel Sambuc 	RL(part = getrawpartition());
5811be35a1SLionel Sambuc 	fname[strlen(fname)-1] = 'a' + part;
5911be35a1SLionel Sambuc 	rump_init();
6011be35a1SLionel Sambuc 	/*
6111be35a1SLionel Sambuc 	 * Rump CD emulation has been fixed, so no longer a problem.
6211be35a1SLionel Sambuc 	 *
6311be35a1SLionel Sambuc 	atf_tc_expect_signal(SIGSEGV, "PR kern/47646: Broken test or "
6411be35a1SLionel Sambuc 	    "a real problem in rump or the driver");
6511be35a1SLionel Sambuc 	 */
6611be35a1SLionel Sambuc 	RL(fd = rump_sys_open(fname, O_RDWR));
6711be35a1SLionel Sambuc 	RL(rump_sys_ioctl(fd, DIOCEJECT, &arg));
6811be35a1SLionel Sambuc 
6911be35a1SLionel Sambuc 	ATF_REQUIRE_EQ(rump_scsitest_err[RUMP_SCSITEST_NOISYSYNC], 0);
7011be35a1SLionel Sambuc 	RL(rump_sys_close(fd));
7111be35a1SLionel Sambuc 	// atf_tc_expect_fail("PR kern/43785");
7211be35a1SLionel Sambuc 	ATF_REQUIRE_EQ(rump_scsitest_err[RUMP_SCSITEST_NOISYSYNC], 0);
7311be35a1SLionel Sambuc }
7411be35a1SLionel Sambuc 
ATF_TP_ADD_TCS(tp)7511be35a1SLionel Sambuc ATF_TP_ADD_TCS(tp)
7611be35a1SLionel Sambuc {
7711be35a1SLionel Sambuc 
7811be35a1SLionel Sambuc 	ATF_TP_ADD_TC(tp, noisyeject);
7911be35a1SLionel Sambuc 
8011be35a1SLionel Sambuc 	return atf_no_error();
8111be35a1SLionel Sambuc }
82