| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /* | 7 /* |
| 8 * NaCl tests for simple syscalls | 8 * NaCl tests for simple syscalls |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 char dirname[PATH_MAX] = { '\0' }; | 167 char dirname[PATH_MAX] = { '\0' }; |
| 168 char newdir[PATH_MAX] = { '\0' }; | 168 char newdir[PATH_MAX] = { '\0' }; |
| 169 char parent[PATH_MAX] = { '\0' }; | 169 char parent[PATH_MAX] = { '\0' }; |
| 170 | 170 |
| 171 char *rtn = getcwd(dirname, PATH_MAX); | 171 char *rtn = getcwd(dirname, PATH_MAX); |
| 172 ASSERT_EQ_MSG(rtn, dirname, "getcwd() failed to return dirname"); | 172 ASSERT_EQ_MSG(rtn, dirname, "getcwd() failed to return dirname"); |
| 173 ASSERT_NE_MSG(strlen(dirname), 0, "getcwd() failed to set valid dirname"); | 173 ASSERT_NE_MSG(strlen(dirname), 0, "getcwd() failed to set valid dirname"); |
| 174 | 174 |
| 175 // Calculate parent folder. | 175 // Calculate parent folder. |
| 176 strncpy(parent, dirname, PATH_MAX); | 176 strncpy(parent, dirname, PATH_MAX); |
| 177 strrchr(parent, '/')[0] = '\0'; | 177 char *basename_start = strrchr(parent, '/'); |
| 178 if (basename_start == NULL) { |
| 179 basename_start = strrchr(parent, '\\'); |
| 180 ASSERT_NE_MSG(basename_start, NULL, "test_file contains no dir seperator"); |
| 181 } |
| 182 basename_start[0] = '\0'; |
| 178 | 183 |
| 179 int retcode = chdir(".."); | 184 int retcode = chdir(".."); |
| 180 ASSERT_EQ_MSG(retcode, 0, "chdir() failed"); | 185 ASSERT_EQ_MSG(retcode, 0, "chdir() failed"); |
| 181 | 186 |
| 182 rtn = getcwd(newdir, PATH_MAX); | 187 rtn = getcwd(newdir, PATH_MAX); |
| 183 ASSERT_EQ_MSG(rtn, newdir, "getcwd() failed"); | 188 ASSERT_EQ_MSG(rtn, newdir, "getcwd() failed"); |
| 184 | 189 |
| 185 ASSERT_MSG(strcmp(newdir, parent) == 0, "getcwd() failed after chdir"); | 190 ASSERT_MSG(strcmp(newdir, parent) == 0, "getcwd() failed after chdir"); |
| 186 retcode = chdir(dirname); | 191 retcode = chdir(dirname); |
| 187 ASSERT_EQ_MSG(retcode, 0, "chdir() failed"); | 192 ASSERT_EQ_MSG(retcode, 0, "chdir() failed"); |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 passed = testSuite(argv[1]); | 675 passed = testSuite(argv[1]); |
| 671 | 676 |
| 672 if (passed) { | 677 if (passed) { |
| 673 printf("All tests PASSED\n"); | 678 printf("All tests PASSED\n"); |
| 674 exit(0); | 679 exit(0); |
| 675 } else { | 680 } else { |
| 676 printf("One or more tests FAILED\n"); | 681 printf("One or more tests FAILED\n"); |
| 677 exit(-1); | 682 exit(-1); |
| 678 } | 683 } |
| 679 } | 684 } |
| OLD | NEW |