4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2014, Intel Corporation.
24 * Use is subject to license terms.
27 #include <sys/types.h>
33 #define perror(str) ((void)0)
35 int main(int argc, char **argv)
38 int fd = open(argv[1], O_WRONLY);
45 /* We need rc because Sles11 compiler warns against unchecked
46 * return value of read and write */
47 rc = write(fd, (void *)0x4096000, 5);
49 perror("write badarea (Should have failed)");
51 rc = write(fd, &fd, 0);
53 perror("write zero bytes");
55 rc = write(fd, &fd, 1);
57 perror("write one byte");
59 rc = write(fd, &fd, 2UL*1024*1024);
60 if (rc != 2UL*1024*1024)
63 rc = write(fd, &fd, 2UL*1024*1024*1024);
64 if (rc != 2UL*1024*1024*1024)
67 rc = write(fd, &fd, -2);
74 fd = open(argv[1], O_RDONLY);
77 rc = read(fd, (void *)0x4096000, 5);
82 /* Tame the compiler spooked about rc assigned, but not used */
84 return -1; /* Not really important. */