1*c54cb811Schristos /* $NetBSD: t_cd.c,v 1.8 2017/01/13 21:30:39 christos Exp $ */
253357666Spooka
353357666Spooka /*
453357666Spooka * Copyright (c) 2010 Antti Kantee. All Rights Reserved.
553357666Spooka *
653357666Spooka * Redistribution and use in source and binary forms, with or without
753357666Spooka * modification, are permitted provided that the following conditions
853357666Spooka * are met:
953357666Spooka * 1. Redistributions of source code must retain the above copyright
1053357666Spooka * notice, this list of conditions and the following disclaimer.
1153357666Spooka * 2. Redistributions in binary form must reproduce the above copyright
1253357666Spooka * notice, this list of conditions and the following disclaimer in the
1353357666Spooka * documentation and/or other materials provided with the distribution.
1453357666Spooka *
1553357666Spooka * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
1653357666Spooka * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1753357666Spooka * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1853357666Spooka * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1953357666Spooka * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2053357666Spooka * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2153357666Spooka * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2253357666Spooka * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2353357666Spooka * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2453357666Spooka * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2553357666Spooka * SUCH DAMAGE.
2653357666Spooka */
2753357666Spooka
2853357666Spooka #include <sys/types.h>
2953357666Spooka #include <sys/ioctl.h>
3053357666Spooka
3153357666Spooka #include <atf-c.h>
3253357666Spooka #include <fcntl.h>
33fcde6153Sjmmv #include <signal.h>
3453357666Spooka #include <stdio.h>
3592474b67Smartin #include <util.h>
3653357666Spooka
3753357666Spooka #include <rump/rump.h>
3853357666Spooka #include <rump/rump_syscalls.h>
390159a35eSpooka
400159a35eSpooka #include "scsitest.h"
4153357666Spooka
42*c54cb811Schristos #include "h_macros.h"
4353357666Spooka
4453357666Spooka ATF_TC(noisyeject);
ATF_TC_HEAD(noisyeject,tc)4553357666Spooka ATF_TC_HEAD(noisyeject, tc)
4653357666Spooka {
4753357666Spooka
4853357666Spooka atf_tc_set_md_var(tc, "descr", "test for CD eject noisyness "
4953357666Spooka "(PR kern/43785)");
5053357666Spooka }
5153357666Spooka
ATF_TC_BODY(noisyeject,tc)5253357666Spooka ATF_TC_BODY(noisyeject, tc)
5353357666Spooka {
5492474b67Smartin static char fname[] = "/dev/rcd0_";
55ec85dd44Smlelstv int part, fd, arg = 0;
5653357666Spooka
57ec85dd44Smlelstv RL(part = getrawpartition());
58ec85dd44Smlelstv fname[strlen(fname)-1] = 'a' + part;
5953357666Spooka rump_init();
6011175263Smartin /*
6111175263Smartin * Rump CD emulation has been fixed, so no longer a problem.
6211175263Smartin *
63fcde6153Sjmmv atf_tc_expect_signal(SIGSEGV, "PR kern/47646: Broken test or "
64fcde6153Sjmmv "a real problem in rump or the driver");
6511175263Smartin */
6692474b67Smartin RL(fd = rump_sys_open(fname, O_RDWR));
6753357666Spooka RL(rump_sys_ioctl(fd, DIOCEJECT, &arg));
6853357666Spooka
6953357666Spooka ATF_REQUIRE_EQ(rump_scsitest_err[RUMP_SCSITEST_NOISYSYNC], 0);
7053357666Spooka RL(rump_sys_close(fd));
71d0518d9cSmartin // atf_tc_expect_fail("PR kern/43785");
7253357666Spooka ATF_REQUIRE_EQ(rump_scsitest_err[RUMP_SCSITEST_NOISYSYNC], 0);
7353357666Spooka }
7453357666Spooka
ATF_TP_ADD_TCS(tp)7553357666Spooka ATF_TP_ADD_TCS(tp)
7653357666Spooka {
7753357666Spooka
7853357666Spooka ATF_TP_ADD_TC(tp, noisyeject);
7953357666Spooka
8053357666Spooka return atf_no_error();
8153357666Spooka }
82