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)
39 void *volatile buf = (void *)0x4096000;
40 void *volatile fd_ptr;
42 fd = open(argv[1], O_WRONLY);
48 /* We need rc because Sles11 compiler warns against unchecked
49 * return value of read and write */
50 rc = write(fd, buf, 5);
52 perror("write badarea (Should have failed)");
55 rc = write(fd, fd_ptr, 0);
57 perror("write zero bytes");
59 rc = write(fd, fd_ptr, 1);
61 perror("write one byte");
63 rc = write(fd, fd_ptr, 2UL*1024*1024);
64 if (rc != 2UL*1024*1024)
67 rc = write(fd, fd_ptr, 2UL*1024*1024*1024);
68 if (rc != 2UL*1024*1024*1024)
71 rc = write(fd, fd_ptr, -2);
78 fd = open(argv[1], O_RDONLY);
81 rc = read(fd, buf, 5);
86 /* Tame the compiler spooked about rc assigned, but not used */
88 return -1; /* Not really important. */