file_descriptor_test.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
  2. // (C) Copyright 2004-2007 Jonathan Turkanis
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  5. // See http://www.boost.org/libs/iostreams for documentation.
  6. #include <fstream>
  7. #include <fcntl.h>
  8. #include <boost/iostreams/device/file_descriptor.hpp>
  9. #include <boost/iostreams/stream.hpp>
  10. #include <boost/test/test_tools.hpp>
  11. #include <boost/test/unit_test.hpp>
  12. #include "detail/temp_file.hpp"
  13. #include "detail/verification.hpp"
  14. #include "detail/file_handle.hpp"
  15. using namespace boost;
  16. using namespace boost::iostreams;
  17. using namespace boost::iostreams::test;
  18. namespace boost_ios = boost::iostreams;
  19. using std::ifstream;
  20. using boost::unit_test::test_suite;
  21. void file_descriptor_test()
  22. {
  23. typedef stream<file_descriptor_source> fdistream;
  24. typedef stream<file_descriptor_sink> fdostream;
  25. typedef stream<file_descriptor> fdstream;
  26. test_file test1;
  27. test_file test2;
  28. //--------------Test file_descriptor_source-------------------------------//
  29. {
  30. fdistream first(file_descriptor_source(test1.name()), 0);
  31. ifstream second(test2.name().c_str());
  32. BOOST_CHECK(first->is_open());
  33. BOOST_CHECK_MESSAGE(
  34. compare_streams_in_chars(first, second),
  35. "failed reading from file_descriptor_source in chars with no buffer"
  36. );
  37. first->close();
  38. BOOST_CHECK(!first->is_open());
  39. }
  40. {
  41. fdistream first(file_descriptor_source(test1.name()), 0);
  42. ifstream second(test2.name().c_str());
  43. BOOST_CHECK(first->is_open());
  44. BOOST_CHECK_MESSAGE(
  45. compare_streams_in_chunks(first, second),
  46. "failed reading from file_descriptor_source in chunks with no buffer"
  47. );
  48. first->close();
  49. BOOST_CHECK(!first->is_open());
  50. }
  51. {
  52. file_descriptor_source file(test1.name());
  53. fdistream first(file);
  54. ifstream second(test2.name().c_str());
  55. BOOST_CHECK(first->is_open());
  56. BOOST_CHECK_MESSAGE(
  57. compare_streams_in_chars(first, second),
  58. "failed reading from file_descriptor_source in chars with buffer"
  59. );
  60. first->close();
  61. BOOST_CHECK(!first->is_open());
  62. }
  63. {
  64. file_descriptor_source file(test1.name());
  65. fdistream first(file);
  66. ifstream second(test2.name().c_str());
  67. BOOST_CHECK(first->is_open());
  68. BOOST_CHECK_MESSAGE(
  69. compare_streams_in_chunks(first, second),
  70. "failed reading from file_descriptor_source in chunks with buffer"
  71. );
  72. first->close();
  73. BOOST_CHECK(!first->is_open());
  74. }
  75. // test illegal flag combinations
  76. {
  77. BOOST_CHECK_THROW(
  78. file_descriptor_source(test1.name(),
  79. BOOST_IOS::trunc),
  80. BOOST_IOSTREAMS_FAILURE);
  81. BOOST_CHECK_THROW(
  82. file_descriptor_source(test1.name(),
  83. BOOST_IOS::app | BOOST_IOS::trunc),
  84. BOOST_IOSTREAMS_FAILURE);
  85. BOOST_CHECK_THROW(
  86. file_descriptor_source(test1.name(),
  87. BOOST_IOS::out),
  88. BOOST_IOSTREAMS_FAILURE);
  89. BOOST_CHECK_THROW(
  90. file_descriptor_source(test1.name(),
  91. BOOST_IOS::out | BOOST_IOS::app),
  92. BOOST_IOSTREAMS_FAILURE);
  93. BOOST_CHECK_THROW(
  94. file_descriptor_source(test1.name(),
  95. BOOST_IOS::out | BOOST_IOS::trunc),
  96. BOOST_IOSTREAMS_FAILURE);
  97. BOOST_CHECK_THROW(
  98. file_descriptor_source(test1.name(),
  99. BOOST_IOS::out | BOOST_IOS::app | BOOST_IOS::trunc),
  100. BOOST_IOSTREAMS_FAILURE);
  101. }
  102. //--------------Test file_descriptor_sink---------------------------------//
  103. {
  104. temp_file temp;
  105. file_descriptor_sink file(temp.name(), BOOST_IOS::trunc);
  106. fdostream out(file, 0);
  107. BOOST_CHECK(out->is_open());
  108. write_data_in_chars(out);
  109. out.close();
  110. BOOST_CHECK_MESSAGE(
  111. compare_files(test1.name(), temp.name()),
  112. "failed writing to file_descriptor_sink in chars with no buffer"
  113. );
  114. file.close();
  115. BOOST_CHECK(!file.is_open());
  116. }
  117. {
  118. temp_file temp;
  119. file_descriptor_sink file(temp.name(), BOOST_IOS::trunc);
  120. fdostream out(file, 0);
  121. BOOST_CHECK(out->is_open());
  122. write_data_in_chunks(out);
  123. out.close();
  124. BOOST_CHECK_MESSAGE(
  125. compare_files(test1.name(), temp.name()),
  126. "failed writing to file_descriptor_sink in chunks with no buffer"
  127. );
  128. file.close();
  129. BOOST_CHECK(!file.is_open());
  130. }
  131. {
  132. temp_file temp;
  133. file_descriptor_sink file(temp.name(), BOOST_IOS::trunc);
  134. fdostream out(file);
  135. BOOST_CHECK(out->is_open());
  136. write_data_in_chars(out);
  137. out.close();
  138. BOOST_CHECK_MESSAGE(
  139. compare_files(test1.name(), temp.name()),
  140. "failed writing to file_descriptor_sink in chars with buffer"
  141. );
  142. file.close();
  143. BOOST_CHECK(!file.is_open());
  144. }
  145. {
  146. temp_file temp;
  147. file_descriptor_sink file(temp.name(), BOOST_IOS::trunc);
  148. fdostream out(file);
  149. BOOST_CHECK(out->is_open());
  150. write_data_in_chunks(out);
  151. out.close();
  152. BOOST_CHECK_MESSAGE(
  153. compare_files(test1.name(), temp.name()),
  154. "failed writing to file_descriptor_sink in chunks with buffer"
  155. );
  156. file.close();
  157. BOOST_CHECK(!file.is_open());
  158. }
  159. {
  160. temp_file temp;
  161. // set up the tests
  162. {
  163. file_descriptor_sink file(temp.name(), BOOST_IOS::trunc);
  164. fdostream out(file);
  165. write_data_in_chunks(out);
  166. out.close();
  167. file.close();
  168. }
  169. // test std::ios_base::app
  170. {
  171. file_descriptor_sink file(temp.name(), BOOST_IOS::app);
  172. fdostream out(file);
  173. BOOST_CHECK(out->is_open());
  174. write_data_in_chars(out);
  175. out.close();
  176. std::string expected(narrow_data());
  177. expected += narrow_data();
  178. BOOST_CHECK_MESSAGE(
  179. compare_container_and_file(expected, temp.name()),
  180. "failed writing to file_descriptor_sink in append mode"
  181. );
  182. file.close();
  183. BOOST_CHECK(!file.is_open());
  184. }
  185. // test std::ios_base::trunc
  186. {
  187. file_descriptor_sink file(temp.name(), BOOST_IOS::trunc);
  188. fdostream out(file);
  189. BOOST_CHECK(out->is_open());
  190. write_data_in_chars(out);
  191. out.close();
  192. BOOST_CHECK_MESSAGE(
  193. compare_files(test1.name(), temp.name()),
  194. "failed writing to file_descriptor_sink in trunc mode"
  195. );
  196. file.close();
  197. BOOST_CHECK(!file.is_open());
  198. }
  199. // test illegal flag combinations
  200. {
  201. BOOST_CHECK_THROW(
  202. file_descriptor_sink(temp.name(),
  203. BOOST_IOS::trunc | BOOST_IOS::app),
  204. BOOST_IOSTREAMS_FAILURE);
  205. BOOST_CHECK_THROW(
  206. file_descriptor_sink(temp.name(),
  207. BOOST_IOS::in),
  208. BOOST_IOSTREAMS_FAILURE);
  209. BOOST_CHECK_THROW(
  210. file_descriptor_sink(temp.name(),
  211. BOOST_IOS::in | BOOST_IOS::app),
  212. BOOST_IOSTREAMS_FAILURE);
  213. BOOST_CHECK_THROW(
  214. file_descriptor_sink(temp.name(),
  215. BOOST_IOS::in | BOOST_IOS::trunc),
  216. BOOST_IOSTREAMS_FAILURE);
  217. BOOST_CHECK_THROW(
  218. file_descriptor_sink(temp.name(),
  219. BOOST_IOS::in | BOOST_IOS::trunc | BOOST_IOS::app),
  220. BOOST_IOSTREAMS_FAILURE);
  221. }
  222. }
  223. //--Test seeking with file_descriptor_source and file_descriptor_sink-----//
  224. test_file test3;
  225. {
  226. file_descriptor_sink sink(test3.name());
  227. fdostream out(sink);
  228. BOOST_CHECK(out->is_open());
  229. BOOST_CHECK_MESSAGE(
  230. test_output_seekable(out),
  231. "failed seeking within a file_descriptor_sink"
  232. );
  233. out->close();
  234. BOOST_CHECK(!out->is_open());
  235. file_descriptor_source source(test3.name());
  236. fdistream in(source);
  237. BOOST_CHECK(in->is_open());
  238. BOOST_CHECK_MESSAGE(
  239. test_input_seekable(in),
  240. "failed seeking within a file_descriptor_source"
  241. );
  242. in->close();
  243. BOOST_CHECK(!in->is_open());
  244. }
  245. //--------------Test file_descriptor--------------------------------------//
  246. {
  247. temp_file temp;
  248. file_descriptor file( temp.name(),
  249. BOOST_IOS::in |
  250. BOOST_IOS::out |
  251. BOOST_IOS::trunc |
  252. BOOST_IOS::binary );
  253. fdstream io(file, BUFSIZ);
  254. BOOST_CHECK_MESSAGE(
  255. test_seekable_in_chars(io),
  256. "failed seeking within a file_descriptor, in chars"
  257. );
  258. }
  259. {
  260. temp_file temp;
  261. file_descriptor file( temp.name(),
  262. BOOST_IOS::in |
  263. BOOST_IOS::out |
  264. BOOST_IOS::trunc |
  265. BOOST_IOS::binary );
  266. fdstream io(file, BUFSIZ);
  267. BOOST_CHECK_MESSAGE(
  268. test_seekable_in_chunks(io),
  269. "failed seeking within a file_descriptor, in chunks"
  270. );
  271. }
  272. //--------------Test read-only file_descriptor----------------------------//
  273. {
  274. fdstream first(file_descriptor(test1.name(), BOOST_IOS::in), 0);
  275. ifstream second(test2.name().c_str());
  276. BOOST_CHECK(first->is_open());
  277. write_data_in_chars(first);
  278. BOOST_CHECK(first.fail());
  279. first.clear();
  280. BOOST_CHECK_MESSAGE(
  281. compare_streams_in_chars(first, second),
  282. "failed reading from file_descriptor in chars with no buffer"
  283. );
  284. first->close();
  285. BOOST_CHECK(!first->is_open());
  286. }
  287. {
  288. fdstream first(file_descriptor(test1.name(), BOOST_IOS::in), 0);
  289. ifstream second(test2.name().c_str());
  290. BOOST_CHECK(first->is_open());
  291. write_data_in_chunks(first);
  292. BOOST_CHECK(first.fail());
  293. first.clear();
  294. BOOST_CHECK_MESSAGE(
  295. compare_streams_in_chunks(first, second),
  296. "failed reading from file_descriptor in chunks with no buffer"
  297. );
  298. first->close();
  299. BOOST_CHECK(!first->is_open());
  300. }
  301. {
  302. file_descriptor file(test1.name(), BOOST_IOS::in);
  303. fdstream first(file);
  304. ifstream second(test2.name().c_str());
  305. BOOST_CHECK(first->is_open());
  306. write_data_in_chars(first);
  307. BOOST_CHECK(first.fail());
  308. first.clear();
  309. first.seekg(0, BOOST_IOS::beg);
  310. BOOST_CHECK_MESSAGE(
  311. compare_streams_in_chars(first, second),
  312. "failed reading from file_descriptor in chars with buffer"
  313. );
  314. first->close();
  315. BOOST_CHECK(!first->is_open());
  316. }
  317. {
  318. file_descriptor file(test1.name(), BOOST_IOS::in);
  319. fdstream first(file);
  320. ifstream second(test2.name().c_str());
  321. BOOST_CHECK(first->is_open());
  322. write_data_in_chunks(first);
  323. BOOST_CHECK(first.fail());
  324. first.clear();
  325. first.seekg(0, BOOST_IOS::beg);
  326. BOOST_CHECK_MESSAGE(
  327. compare_streams_in_chunks(first, second),
  328. "failed reading from file_descriptor in chunks with buffer"
  329. );
  330. first->close();
  331. BOOST_CHECK(!first->is_open());
  332. }
  333. //--------------Test write-only file_descriptor---------------------------//
  334. {
  335. temp_file temp;
  336. file_descriptor file( temp.name(),
  337. BOOST_IOS::out |
  338. BOOST_IOS::trunc );
  339. fdstream out(file, 0);
  340. BOOST_CHECK(out->is_open());
  341. out.get();
  342. BOOST_CHECK(out.fail());
  343. out.clear();
  344. write_data_in_chars(out);
  345. out.seekg(0, BOOST_IOS::beg);
  346. out.get();
  347. BOOST_CHECK(out.fail());
  348. out.clear();
  349. out.close();
  350. BOOST_CHECK_MESSAGE(
  351. compare_files(test1.name(), temp.name()),
  352. "failed writing to file_descriptor in chars with no buffer"
  353. );
  354. file.close();
  355. BOOST_CHECK(!file.is_open());
  356. }
  357. {
  358. temp_file temp;
  359. file_descriptor file( temp.name(),
  360. BOOST_IOS::out |
  361. BOOST_IOS::trunc );
  362. fdstream out(file, 0);
  363. BOOST_CHECK(out->is_open());
  364. out.get();
  365. BOOST_CHECK(out.fail());
  366. out.clear();
  367. write_data_in_chunks(out);
  368. out.seekg(0, BOOST_IOS::beg);
  369. out.get();
  370. BOOST_CHECK(out.fail());
  371. out.clear();
  372. out.close();
  373. BOOST_CHECK_MESSAGE(
  374. compare_files(test1.name(), temp.name()),
  375. "failed writing to file_descriptor_sink in chunks with no buffer"
  376. );
  377. file.close();
  378. BOOST_CHECK(!file.is_open());
  379. }
  380. {
  381. temp_file temp;
  382. file_descriptor file( temp.name(),
  383. BOOST_IOS::out |
  384. BOOST_IOS::trunc );
  385. fdstream out(file);
  386. BOOST_CHECK(out->is_open());
  387. out.get();
  388. BOOST_CHECK(out.fail());
  389. out.clear();
  390. write_data_in_chars(out);
  391. out.seekg(0, BOOST_IOS::beg);
  392. out.get();
  393. BOOST_CHECK(out.fail());
  394. out.clear();
  395. out.close();
  396. BOOST_CHECK_MESSAGE(
  397. compare_files(test1.name(), temp.name()),
  398. "failed writing to file_descriptor_sink in chars with buffer"
  399. );
  400. file.close();
  401. BOOST_CHECK(!file.is_open());
  402. }
  403. {
  404. temp_file temp;
  405. file_descriptor file( temp.name(),
  406. BOOST_IOS::out |
  407. BOOST_IOS::trunc );
  408. fdstream out(file);
  409. BOOST_CHECK(out->is_open());
  410. out.get();
  411. BOOST_CHECK(out.fail());
  412. out.clear();
  413. write_data_in_chunks(out);
  414. out.seekg(0, BOOST_IOS::beg);
  415. out.get();
  416. BOOST_CHECK(out.fail());
  417. out.clear();
  418. out.close();
  419. BOOST_CHECK_MESSAGE(
  420. compare_files(test1.name(), temp.name()),
  421. "failed writing to file_descriptor_sink in chunks with buffer"
  422. );
  423. file.close();
  424. BOOST_CHECK(!file.is_open());
  425. }
  426. // test illegal flag combinations
  427. {
  428. BOOST_CHECK_THROW(
  429. file_descriptor(test1.name(),
  430. BOOST_IOS::openmode(0)),
  431. BOOST_IOSTREAMS_FAILURE);
  432. BOOST_CHECK_THROW(
  433. file_descriptor(test1.name(),
  434. BOOST_IOS::trunc),
  435. BOOST_IOSTREAMS_FAILURE);
  436. BOOST_CHECK_THROW(
  437. file_descriptor(test1.name(),
  438. BOOST_IOS::app | BOOST_IOS::trunc),
  439. BOOST_IOSTREAMS_FAILURE);
  440. BOOST_CHECK_THROW(
  441. file_descriptor(test1.name(),
  442. BOOST_IOS::in | BOOST_IOS::trunc),
  443. BOOST_IOSTREAMS_FAILURE);
  444. BOOST_CHECK_THROW(
  445. file_descriptor(test1.name(),
  446. BOOST_IOS::in | BOOST_IOS::app | BOOST_IOS::trunc),
  447. BOOST_IOSTREAMS_FAILURE);
  448. BOOST_CHECK_THROW(
  449. file_descriptor(test1.name(),
  450. BOOST_IOS::out | BOOST_IOS::app | BOOST_IOS::trunc),
  451. BOOST_IOSTREAMS_FAILURE);
  452. BOOST_CHECK_THROW(
  453. file_descriptor(test1.name(),
  454. BOOST_IOS::in |
  455. BOOST_IOS::out |
  456. BOOST_IOS::app |
  457. BOOST_IOS::trunc),
  458. BOOST_IOSTREAMS_FAILURE);
  459. }
  460. }
  461. template <class FileDescriptor>
  462. void file_handle_test_impl(FileDescriptor*)
  463. {
  464. test_file test1;
  465. test_file test2;
  466. {
  467. boost_ios::detail::file_handle handle = open_file_handle(test1.name());
  468. {
  469. FileDescriptor device1(handle, boost_ios::never_close_handle);
  470. BOOST_CHECK(device1.handle() == handle);
  471. }
  472. BOOST_CHECK_HANDLE_OPEN(handle);
  473. close_file_handle(handle);
  474. }
  475. {
  476. boost_ios::detail::file_handle handle = open_file_handle(test1.name());
  477. {
  478. FileDescriptor device1(handle, boost_ios::close_handle);
  479. BOOST_CHECK(device1.handle() == handle);
  480. }
  481. BOOST_CHECK_HANDLE_CLOSED(handle);
  482. }
  483. {
  484. boost_ios::detail::file_handle handle = open_file_handle(test1.name());
  485. FileDescriptor device1(handle, boost_ios::never_close_handle);
  486. BOOST_CHECK(device1.handle() == handle);
  487. device1.close();
  488. BOOST_CHECK(!device1.is_open());
  489. BOOST_CHECK_HANDLE_OPEN(handle);
  490. close_file_handle(handle);
  491. }
  492. {
  493. boost_ios::detail::file_handle handle = open_file_handle(test1.name());
  494. FileDescriptor device1(handle, boost_ios::close_handle);
  495. BOOST_CHECK(device1.handle() == handle);
  496. device1.close();
  497. BOOST_CHECK(!device1.is_open());
  498. BOOST_CHECK_HANDLE_CLOSED(handle);
  499. }
  500. {
  501. boost_ios::detail::file_handle handle1 = open_file_handle(test1.name());
  502. boost_ios::detail::file_handle handle2 = open_file_handle(test2.name());
  503. {
  504. FileDescriptor device1(handle1, boost_ios::never_close_handle);
  505. BOOST_CHECK(device1.handle() == handle1);
  506. device1.open(handle2, boost_ios::never_close_handle);
  507. BOOST_CHECK(device1.handle() == handle2);
  508. }
  509. BOOST_CHECK_HANDLE_OPEN(handle1);
  510. BOOST_CHECK_HANDLE_OPEN(handle2);
  511. close_file_handle(handle1);
  512. close_file_handle(handle2);
  513. }
  514. {
  515. boost_ios::detail::file_handle handle1 = open_file_handle(test1.name());
  516. boost_ios::detail::file_handle handle2 = open_file_handle(test2.name());
  517. {
  518. FileDescriptor device1(handle1, boost_ios::close_handle);
  519. BOOST_CHECK(device1.handle() == handle1);
  520. device1.open(handle2, boost_ios::close_handle);
  521. BOOST_CHECK(device1.handle() == handle2);
  522. BOOST_CHECK_HANDLE_CLOSED(handle1);
  523. BOOST_CHECK_HANDLE_OPEN(handle2);
  524. }
  525. BOOST_CHECK_HANDLE_CLOSED(handle1);
  526. BOOST_CHECK_HANDLE_CLOSED(handle2);
  527. }
  528. {
  529. boost_ios::detail::file_handle handle1 = open_file_handle(test1.name());
  530. boost_ios::detail::file_handle handle2 = open_file_handle(test2.name());
  531. {
  532. FileDescriptor device1(handle1, boost_ios::close_handle);
  533. BOOST_CHECK(device1.handle() == handle1);
  534. device1.open(handle2, boost_ios::never_close_handle);
  535. BOOST_CHECK(device1.handle() == handle2);
  536. BOOST_CHECK_HANDLE_CLOSED(handle1);
  537. BOOST_CHECK_HANDLE_OPEN(handle2);
  538. }
  539. BOOST_CHECK_HANDLE_CLOSED(handle1);
  540. BOOST_CHECK_HANDLE_OPEN(handle2);
  541. close_file_handle(handle2);
  542. }
  543. {
  544. boost_ios::detail::file_handle handle = open_file_handle(test1.name());
  545. {
  546. FileDescriptor device1;
  547. BOOST_CHECK(!device1.is_open());
  548. device1.open(handle, boost_ios::never_close_handle);
  549. BOOST_CHECK(device1.handle() == handle);
  550. BOOST_CHECK_HANDLE_OPEN(handle);
  551. }
  552. BOOST_CHECK_HANDLE_OPEN(handle);
  553. close_file_handle(handle);
  554. }
  555. {
  556. boost_ios::detail::file_handle handle = open_file_handle(test1.name());
  557. {
  558. FileDescriptor device1;
  559. BOOST_CHECK(!device1.is_open());
  560. device1.open(handle, boost_ios::close_handle);
  561. BOOST_CHECK(device1.handle() == handle);
  562. BOOST_CHECK_HANDLE_OPEN(handle);
  563. }
  564. BOOST_CHECK_HANDLE_CLOSED(handle);
  565. }
  566. }
  567. void file_handle_test()
  568. {
  569. file_handle_test_impl((boost_ios::file_descriptor*) 0);
  570. file_handle_test_impl((boost_ios::file_descriptor_source*) 0);
  571. file_handle_test_impl((boost_ios::file_descriptor_sink*) 0);
  572. }
  573. test_suite* init_unit_test_suite(int, char* [])
  574. {
  575. test_suite* test = BOOST_TEST_SUITE("file_descriptor test");
  576. test->add(BOOST_TEST_CASE(&file_descriptor_test));
  577. test->add(BOOST_TEST_CASE(&file_handle_test));
  578. return test;
  579. }