1272343Sngie/* $NetBSD: t_basic.c,v 1.2 2011/02/22 13:25:18 pooka Exp $ */ 2272343Sngie 3272343Sngie/*- 4272343Sngie * Copyright (c) 2011 The NetBSD Foundation, Inc. 5272343Sngie * All rights reserved. 6272343Sngie * 7272343Sngie * Redistribution and use in source and binary forms, with or without 8272343Sngie * modification, are permitted provided that the following conditions 9272343Sngie * are met: 10272343Sngie * 1. Redistributions of source code must retain the above copyright 11272343Sngie * notice, this list of conditions and the following disclaimer. 12272343Sngie * 2. Redistributions in binary form must reproduce the above copyright 13272343Sngie * notice, this list of conditions and the following disclaimer in the 14272343Sngie * documentation and/or other materials provided with the distribution. 15272343Sngie * 16272343Sngie * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND 17272343Sngie * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 18272343Sngie * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19272343Sngie * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20272343Sngie * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 21272343Sngie * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22272343Sngie * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 23272343Sngie * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24272343Sngie * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25272343Sngie * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26272343Sngie * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27272343Sngie * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28272343Sngie */ 29272343Sngie 30272343Sngie#include <sys/types.h> 31272343Sngie#include <sys/mount.h> 32272343Sngie#include <sys/sysctl.h> 33272343Sngie 34272343Sngie#include <rump/rump.h> 35272343Sngie#include <rump/rump_syscalls.h> 36272343Sngie 37272343Sngie#include <atf-c.h> 38272343Sngie#include <fcntl.h> 39272343Sngie#include <stdio.h> 40272343Sngie#include <stdlib.h> 41272343Sngie#include <unistd.h> 42272343Sngie 43272343Sngie#include "../../h_macros.h" 44272343Sngie 45272343SngieATF_TC(lseekrv); 46272343SngieATF_TC_HEAD(lseekrv, tc) 47272343Sngie{ 48272343Sngie 49272343Sngie atf_tc_set_md_var(tc, "descr", "Test lseek return values"); 50272343Sngie} 51272343Sngie 52272343Sngie#define TESTFILE "testi" 53272343Sngie 54272343Sngie#define FIVE_MEGS (5*1024*1024) 55272343Sngie#define FIVE_GIGS (5*1024*1024*1024LL) 56272343Sngie 57272343SngieATF_TC_BODY(lseekrv, tc) 58272343Sngie{ 59272343Sngie off_t rv; 60272343Sngie int fd; 61272343Sngie 62272343Sngie RZ(rump_init()); 63272343Sngie RL(fd = rump_sys_open(TESTFILE, O_RDWR | O_CREAT, 0777)); 64272343Sngie 65272343Sngie rv = rump_sys_lseek(37, FIVE_MEGS, SEEK_SET); 66272343Sngie ATF_REQUIRE_ERRNO(EBADF, rv == -1); 67272343Sngie 68272343Sngie rv = rump_sys_lseek(fd, FIVE_MEGS, SEEK_SET); 69272343Sngie ATF_REQUIRE_EQ(rv, FIVE_MEGS); 70272343Sngie 71272343Sngie rv = rump_sys_lseek(fd, FIVE_GIGS, SEEK_SET); 72272343Sngie ATF_REQUIRE_EQ(rv, FIVE_GIGS); 73272343Sngie} 74272343Sngie 75272343SngieATF_TP_ADD_TCS(tp) 76272343Sngie{ 77272343Sngie 78272343Sngie ATF_TP_ADD_TC(tp, lseekrv); 79272343Sngie 80272343Sngie return atf_no_error(); 81272343Sngie} 82