| 1311 | } |
| 1312 | |
| 1313 | void |
| 1314 | hstest_thread::test_21(int num) |
| 1315 | { |
| 1316 | /* fsync test */ |
| 1317 | unsigned int id = arg.id; |
| 1318 | std::string err; |
| 1319 | #if 0 |
| 1320 | if (socket_connect(fd, arg.sh.arg, err) != 0) { |
| 1321 | fprintf(stderr, "connect: %d %s\n", errno, strerror(errno)); |
| 1322 | return; |
| 1323 | } |
| 1324 | #endif |
| 1325 | auto_file logfd; |
| 1326 | char fname[1024]; |
| 1327 | snprintf(fname, sizeof(fname), "synctest_%u", id); |
| 1328 | int open_flags = O_WRONLY | O_CREAT | O_TRUNC | O_APPEND; |
| 1329 | logfd.reset(open(fname, open_flags, 0644)); |
| 1330 | if (logfd.get() < 0) { |
| 1331 | fprintf(stderr, "open: %s: %d %s\n", fname, errno, strerror(errno)); |
| 1332 | return; |
| 1333 | } |
| 1334 | char buf[1024]; |
| 1335 | unsigned long long count = 0; |
| 1336 | while (true) { |
| 1337 | snprintf(buf, sizeof(buf), "%u %llu\n", id, count); |
| 1338 | const size_t len = strlen(buf); |
| 1339 | if (write(logfd.get(), buf, len) != (ssize_t)len) { |
| 1340 | fprintf(stderr, "write: %s: %d %s\n", fname, errno, strerror(errno)); |
| 1341 | return; |
| 1342 | } |
| 1343 | #if 0 |
| 1344 | if (write(fd.get(), buf, len) != (ssize_t)len) { |
| 1345 | fprintf(stderr, "write(sock): %d %s\n", errno, strerror(errno)); |
| 1346 | return; |
| 1347 | } |
| 1348 | #endif |
| 1349 | if (fdatasync(logfd.get()) != 0) { |
| 1350 | fprintf(stderr, "fsync: %s: %d %s\n", fname, errno, strerror(errno)); |
| 1351 | return; |
| 1352 | } |
| 1353 | ++count; |
| 1354 | ++op_success_count; |
| 1355 | arg.sh.increment_count(); |
| 1356 | } |
| 1357 | } |
| 1358 | |
| 1359 | void |
| 1360 | hstest_thread::test_22(int num) |
nothing calls this directly
no test coverage detected