subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * sync_file_range01.c |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 3 | * Copyright (c) International Business Machines Corp., 2008 |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 4 | * Email: bnpoorni@in.ibm.com |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 5 | *****************************************************************************/ |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 6 | |
| 7 | /******************************************************************************/ |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 8 | /* */ |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 9 | /* This program is free software; you can redistribute it and/or modify */ |
| 10 | /* it under the terms of the GNU General Public License as published by */ |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 11 | /* the Free Software Foundation; either version 2 of the License, or */ |
| 12 | /* (at your option) any later version. */ |
| 13 | /* */ |
| 14 | /* This program is distributed in the hope that it will be useful, */ |
| 15 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
| 16 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ |
| 17 | /* the GNU General Public License for more details. */ |
| 18 | /* */ |
| 19 | /* You should have received a copy of the GNU General Public License */ |
| 20 | /* along with this program; if not, write to the Free Software */ |
Wanlong Gao | 4548c6c | 2012-10-19 18:03:36 +0800 | [diff] [blame] | 21 | /* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 22 | /* */ |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 23 | /******************************************************************************/ |
| 24 | |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 25 | /***************************************************************************** |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 26 | * TEST IDENTIFIER : sync_file_range01 $ |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 27 | * $ |
| 28 | * EXECUTED BY : anyone $ |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 29 | * |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 30 | * TEST TITLE : Checks for Errors from sync_file_range() |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 31 | * |
| 32 | * TEST CASE TOTAL : 5 |
| 33 | * |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 34 | * CPU ARCHITECTURES : All |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 35 | * |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 36 | * AUTHOR : B N Poornima |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 37 | * |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 38 | * DATE STARTED : 21/07/2008 |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 39 | * |
| 40 | * TEST CASES |
| 41 | * (Tests sync_file_range() for different test cases as reported in the man |
| 42 | * page) |
| 43 | * |
| 44 | * INPUT SPECIFICATIONS |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 45 | * No input needs to be specified |
| 46 | * sync_file_data() in-puts are specified through test_data |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 47 | * |
| 48 | * OUTPUT SPECIFICATIONS |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 49 | * sync_file_data() error message matches with the expected error |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 50 | * message. |
| 51 | * |
| 52 | * ENVIRONMENTAL NEEDS |
| 53 | * Kernel version 2.6.17 and above |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 54 | * Kernel version 2.6.22 and above in case of PPC and PPC64 |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 55 | * |
| 56 | * SPECIAL PROCEDURAL REQUIREMENTS |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 57 | * None |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 58 | * |
| 59 | * DETAILED DESCRIPTION |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 60 | * This is a test case for sync_file_range() system call. |
| 61 | * This test suite tests various error messages from the system call |
| 62 | * If the error message received matches with the expected |
| 63 | * test is considered passed else test fails |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 64 | * |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 65 | * Total 5 Test Cases :- |
| 66 | * Various error messages from the man page |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 67 | * |
| 68 | * Setup: |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 69 | * Setup files on which sync_file_range is to be called |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 70 | * |
| 71 | * Test: |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 72 | * Loop if the proper options are given. |
| 73 | * Execute system call |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 74 | * Check return code. |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 75 | * If error obtained matches with the expected error |
| 76 | * PASS the test, otherwise TEST FAILS |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 77 | * |
| 78 | * Cleanup: |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 79 | * Cleanup the temporary folder |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 80 | * |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 81 | ******************************************************************************/ |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 82 | #define _GNU_SOURCE |
| 83 | |
Garrett Cooper | e060c49 | 2010-10-23 22:23:13 -0700 | [diff] [blame] | 84 | #include <sys/types.h> |
| 85 | #include <sys/stat.h> |
| 86 | #include <sys/utsname.h> |
| 87 | #include <endian.h> |
| 88 | #include <errno.h> |
| 89 | #include <fcntl.h> |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 90 | #include <stdio.h> |
| 91 | #include <stdlib.h> |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 92 | #include <unistd.h> |
| 93 | |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 94 | #include "test.h" |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 95 | #include "linux_syscall_numbers.h" |
| 96 | |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 97 | #ifndef SYNC_FILE_RANGE_WAIT_BEFORE |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 98 | #define SYNC_FILE_RANGE_WAIT_BEFORE 1 |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 99 | #define SYNC_FILE_RANGE_WRITE 2 //DUMMY VALUES |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 100 | #define SYNC_FILE_RANGE_WAIT_AFTER 4 |
| 101 | #endif |
| 102 | |
| 103 | #define SYNC_FILE_RANGE_INVALID 8 |
| 104 | |
Cyril Hrubis | fdce7d5 | 2013-04-04 18:35:48 +0200 | [diff] [blame] | 105 | char *TCID = "sync_file_range01"; |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 106 | char filename[255]; /* file used for testing */ |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 107 | char spl_file[] = "/dev/null"; |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 108 | int filed, sfd; /* normal and special fds */ |
| 109 | int bfd = -1; /* Bad file descriptor */ |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 110 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 111 | struct test_data_t { |
| 112 | int *fd; |
| 113 | off64_t offset; |
| 114 | off64_t nbytes; |
| 115 | unsigned int flags; |
| 116 | int error; |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 117 | } test_data[] = { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 118 | { |
| 119 | &bfd, 0, 1, SYNC_FILE_RANGE_WRITE, EBADF}, { |
| 120 | &sfd, 0, 1, SYNC_FILE_RANGE_WAIT_AFTER, ESPIPE}, { |
| 121 | &filed, -1, 1, SYNC_FILE_RANGE_WAIT_BEFORE, EINVAL}, { |
| 122 | &filed, 0, -1, SYNC_FILE_RANGE_WRITE, EINVAL}, { |
| 123 | &filed, 0, 1, SYNC_FILE_RANGE_INVALID, EINVAL} |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 124 | }; |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 125 | |
| 126 | int TST_TOTAL = sizeof(test_data) / sizeof(test_data[0]); |
| 127 | |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 128 | /* Extern Global Functions */ |
| 129 | /******************************************************************************/ |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 130 | /* */ |
| 131 | /* Function: cleanup */ |
| 132 | /* */ |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 133 | /* Description: Performs all one time clean up for this test on successful */ |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 134 | /* completion, premature exit or failure. Closes all temporary */ |
| 135 | /* files, removes all temporary directories exits the test with */ |
| 136 | /* appropriate return code by calling tst_exit() function. */ |
| 137 | /* */ |
| 138 | /* Input: None. */ |
| 139 | /* */ |
| 140 | /* Output: None. */ |
| 141 | /* */ |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 142 | /* Return: On failure - Exits calling tst_exit(). Non '0' return code. */ |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 143 | /* On success - Exits calling tst_exit(). With '0' return code. */ |
| 144 | /* */ |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 145 | /******************************************************************************/ |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 146 | void cleanup(void) |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 147 | { |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 148 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 149 | /* close the file we have open */ |
| 150 | if (close(filed) == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 151 | tst_resm(TWARN | TERRNO, "close(%s) failed", filename); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 152 | } |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 153 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 154 | tst_rmdir(); |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 155 | } |
| 156 | |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 157 | /* Local Functions */ |
| 158 | /******************************************************************************/ |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 159 | /* */ |
| 160 | /* Function: setup */ |
| 161 | /* */ |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 162 | /* Description: Performs all one time setup for this test. This function is */ |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 163 | /* typically used to capture signals, create temporary dirs */ |
| 164 | /* and temporary files that may be used in the course of this */ |
| 165 | /* test. */ |
| 166 | /* */ |
| 167 | /* Input: None. */ |
| 168 | /* */ |
| 169 | /* Output: None. */ |
| 170 | /* */ |
| 171 | /* Return: On failure - Exits by calling cleanup(). */ |
| 172 | /* On success - returns 0. */ |
| 173 | /* */ |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 174 | /******************************************************************************/ |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 175 | void setup(void) |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 176 | { |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 177 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 178 | tst_sig(NOFORK, DEF_HANDLER, cleanup); |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 179 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 180 | TEST_PAUSE; |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 181 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 182 | tst_tmpdir(); |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 183 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 184 | sprintf(filename, "tmpfile_%d", getpid()); |
| 185 | if ((filed = open(filename, O_RDWR | O_CREAT, 0700)) == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 186 | tst_brkm(TBROK | TERRNO, cleanup, |
Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 187 | "open(%s, O_RDWR|O_CREAT,0700) failed", filename); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 188 | } |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 189 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 190 | sfd = open(spl_file, O_RDWR | O_CREAT, 0700); |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | /***************************************************************************** |
| 194 | * Wraper function to call sync_file_range system call |
| 195 | ******************************************************************************/ |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 196 | static inline long syncfilerange(int fd, off64_t offset, off64_t nbytes, |
| 197 | unsigned int flags) |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 198 | { |
| 199 | |
Garrett Cooper | 2e27803 | 2010-11-22 01:14:14 -0800 | [diff] [blame] | 200 | #if (defined(__arm__) || defined(__powerpc__) || defined(__powerpc64__)) |
| 201 | #if (__WORDSIZE == 32) |
Garrett Cooper | 9bed07c | 2010-10-23 21:56:44 -0700 | [diff] [blame] | 202 | #if __BYTE_ORDER == __BIG_ENDIAN |
Jan Stancek | 359980f | 2013-02-15 10:16:05 +0100 | [diff] [blame] | 203 | return ltp_syscall(__NR_sync_file_range2, fd, flags, |
| 204 | (int)(offset >> 32), (int)offset, (int)(nbytes >> 32), |
| 205 | (int)nbytes); |
Garrett Cooper | 9bed07c | 2010-10-23 21:56:44 -0700 | [diff] [blame] | 206 | #elif __BYTE_ORDER == __LITTLE_ENDIAN |
Jan Stancek | 359980f | 2013-02-15 10:16:05 +0100 | [diff] [blame] | 207 | return ltp_syscall(__NR_sync_file_range2, fd, flags, (int)offset, |
Garrett Cooper | 9bed07c | 2010-10-23 21:56:44 -0700 | [diff] [blame] | 208 | (int)(offset >> 32), nbytes, (int)(nbytes >> 32)); |
Garrett Cooper | 2e27803 | 2010-11-22 01:14:14 -0800 | [diff] [blame] | 209 | #endif |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 210 | #else |
Jan Stancek | 359980f | 2013-02-15 10:16:05 +0100 | [diff] [blame] | 211 | return ltp_syscall(__NR_sync_file_range2, fd, flags, offset, nbytes); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 212 | #endif |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 213 | #else |
Jan Stancek | 359980f | 2013-02-15 10:16:05 +0100 | [diff] [blame] | 214 | return ltp_syscall(__NR_sync_file_range, fd, offset, nbytes, flags); |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 215 | #endif |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 216 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 217 | } |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 218 | |
| 219 | /******************************************************************************/ |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 220 | /* */ |
| 221 | /* Function: main */ |
| 222 | /* */ |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 223 | /* Description: Entry point to this test-case. It parses all the command line */ |
Garrett Cooper | 5e8be51 | 2010-11-22 01:12:27 -0800 | [diff] [blame] | 224 | /* inputs, calls the global setup and executes the test. It logs */ |
| 225 | /* the test status and results appropriately using the LTP API's */ |
| 226 | /* On successful completion or premature failure, cleanup() func */ |
| 227 | /* is called and test exits with an appropriate return code. */ |
| 228 | /* */ |
| 229 | /* Input: Describe input arguments to this test-case */ |
| 230 | /* -l - Number of iteration */ |
| 231 | /* -v - Prints verbose output */ |
| 232 | /* -V - Prints the version number */ |
| 233 | /* */ |
| 234 | /* Exit: On failure - Exits by calling cleanup(). */ |
| 235 | /* On success - exits with 0 exit value. */ |
| 236 | /* */ |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 237 | /******************************************************************************/ |
Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 238 | int main(int ac, char **av) |
| 239 | { |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 240 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 241 | int test_index = 0; |
Cyril Hrubis | 0b9589f | 2014-05-27 17:40:33 +0200 | [diff] [blame] | 242 | const char *msg; |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 243 | |
Garrett Cooper | 45e285d | 2010-11-22 12:19:25 -0800 | [diff] [blame] | 244 | if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) |
Garrett Cooper | 60fa801 | 2010-11-22 13:50:58 -0800 | [diff] [blame] | 245 | tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 246 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 247 | #if defined(__powerpc__) || defined(__powerpc64__) /* for PPC, kernel version > 2.6.21 needed */ |
Garrett Cooper | dd65a99 | 2010-10-25 23:58:48 -0700 | [diff] [blame] | 248 | if (tst_kvercmp(2, 16, 22) < 0) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 249 | tst_brkm(TCONF, NULL, |
| 250 | "System doesn't support execution of the test"); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 251 | } |
subrata_modak | 5335e9d | 2008-08-22 21:23:40 +0000 | [diff] [blame] | 252 | #else |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 253 | /* For other archs, need kernel version > 2.6.16 */ |
subrata_modak | 5335e9d | 2008-08-22 21:23:40 +0000 | [diff] [blame] | 254 | |
Garrett Cooper | dd65a99 | 2010-10-25 23:58:48 -0700 | [diff] [blame] | 255 | if (tst_kvercmp(2, 6, 17) < 0) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 256 | tst_brkm(TCONF, NULL, |
| 257 | "System doesn't support execution of the test"); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 258 | } |
subrata_modak | 5335e9d | 2008-08-22 21:23:40 +0000 | [diff] [blame] | 259 | #endif |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 260 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 261 | setup(); |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 262 | |
Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 263 | for (test_index = 0; test_index < TST_TOTAL; test_index++) { |
| 264 | TEST(syncfilerange |
| 265 | (*(test_data[test_index].fd), |
| 266 | test_data[test_index].offset, |
| 267 | test_data[test_index].nbytes, |
| 268 | test_data[test_index].flags)); |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 269 | |
Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 270 | if (TEST_RETURN != -1) { |
| 271 | tst_resm(TFAIL, |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 272 | "call succeeded unexpectedly (%ld != -1)", |
| 273 | TEST_RETURN); |
Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 274 | continue; |
| 275 | } |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 276 | |
Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 277 | if (TEST_ERRNO == test_data[test_index].error) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 278 | tst_resm(TPASS | TTERRNO, "got expected error"); |
Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 279 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 280 | tst_resm(TFAIL | TTERRNO, "got unexpected error; " |
| 281 | "expected %d", test_data[test_index].error); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 282 | } |
subrata_modak | b1ef993 | 2008-08-18 10:37:42 +0000 | [diff] [blame] | 283 | |
| 284 | } |
| 285 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 286 | cleanup(); |
Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 287 | tst_exit(); |
Chris Dearman | ec6edca | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 288 | } |