olias_test.C 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*
  24. * $XConsortium: olias_test.C /main/8 1996/10/26 18:20:03 cde-hal $
  25. *
  26. * Copyright (c) 1992 HAL Computer Systems International, Ltd.
  27. * All rights reserved. Unpublished -- rights reserved under
  28. * the Copyright Laws of the United States. USE OF A COPYRIGHT
  29. * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
  30. * OR DISCLOSURE.
  31. *
  32. * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
  33. * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
  34. * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
  35. * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
  36. * INTERNATIONAL, LTD.
  37. *
  38. * RESTRICTED RIGHTS LEGEND
  39. * Use, duplication, or disclosure by the Government is subject
  40. * to the restrictions as set forth in subparagraph (c)(l)(ii)
  41. * of the Rights in Technical Data and Computer Software clause
  42. * at DFARS 252.227-7013.
  43. *
  44. * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
  45. * 1315 Dell Avenue
  46. * Campbell, CA 95008
  47. *
  48. */
  49. #include "oliasdb/olias_test.h"
  50. #include "api/utility.h"
  51. #include "utility/pm_random.h"
  52. #include "misc/unique_id.h"
  53. #include "storage/vm_storage.h"
  54. #include "dstr/dstr_test.h"
  55. #include "storage/store_test.h"
  56. #include "oliasdb/olias_funcs.h"
  57. #include "object/random_gen.h"
  58. #ifdef REGRESSION_TEST
  59. #include "oliasdb/graphic_test.h"
  60. #include "oliasdb/loc_test.h"
  61. #include "oliasdb/stylesheet_test.h"
  62. #include "oliasdb/dlp_test.h"
  63. #include "oliasdb/mark_test.h"
  64. #include "oliasdb/toc_test.h"
  65. #include "oliasdb/doc_test.h"
  66. #include "oliasdb/node_test.h"
  67. #endif
  68. #include "oliasdb/collectionIterator.h"
  69. #include "oliasdb/mmdb.h"
  70. #ifdef NODEBUG
  71. void test_collector_iterator(info_base* base)
  72. {
  73. MESSAGE(cerr, "node locators:");
  74. nodeCollectionIterator x(base);
  75. while ( ++x ) {
  76. debug(cerr, x.get_locator());
  77. }
  78. MESSAGE(cerr, "stylesheet locators:");
  79. stylesheetCollectionIterator y(base);
  80. while ( ++y ) {
  81. debug(cerr, y.get_locator());
  82. }
  83. MESSAGE(cerr, "locator set locators:");
  84. locatorCollectionIterator z(base);
  85. while ( ++z ) {
  86. debug(cerr, z.get_locator());
  87. }
  88. }
  89. int dump_instances(info_base* base_ptr, char* col_nm, c_code_t ins_code)
  90. {
  91. if ( base_ptr == 0 )
  92. throw(stringException("null base ptr"));
  93. Iterator *it = base_ptr -> first(col_nm, ins_code);
  94. if (it==0)
  95. throw(stringException("null iterator pointer"));
  96. int i = 0;
  97. while ( *it ) {
  98. oid_t id = base_ptr -> get_oid(*it);
  99. if ( strcmp(col_nm, NODE_SET_NAME) == 0 ) {
  100. i++;
  101. node_smart_ptr x(base_ptr, id);
  102. cout << x.data();
  103. //debug(cerr, x.long_title());
  104. } else
  105. if ( strcmp(col_nm, LOCATOR_SET_NAME) == 0 ) {
  106. i++;
  107. locator_smart_ptr x(base_ptr, id);
  108. cout << x.inside_node_locator_str() << "\n";
  109. }
  110. if ( strcmp(col_nm, GRAPHIC_SET_NAME) == 0 ) {
  111. i++;
  112. graphic_smart_ptr x(base_ptr, id);
  113. if ( x.type() == 3 ) {
  114. const char* ps_str = x.data();
  115. cout << "\n";
  116. cout << "\n";
  117. cout << x.data_size() << "\t";
  118. for ( int j=0; j<x.data_size(); j++ )
  119. cout << ps_str[j];
  120. cout << "\n";
  121. }
  122. }
  123. base_ptr -> next(*it);
  124. }
  125. debug(cerr, i);
  126. delete it;
  127. return 0;
  128. }
  129. int cache_test( info_lib* infolib_ptr, const char* base_name, int argc, char** argv )
  130. {
  131. locator_smart_ptrPtr* ptr_array = new locator_smart_ptrPtr[argc];
  132. debug(cerr, argc);
  133. int i;
  134. for ( i=0; i<argc; i++ ) {
  135. ptr_array[i] = new locator_smart_ptr(infolib_ptr, base_name, argv[i]);
  136. cerr << form("node_id of locator %s:\n", argv[i]);
  137. ptr_array[i] -> node_id().asciiOut(cerr); cerr << "\n";
  138. //debug(cerr, ptr_array[i] -> vcc_num());
  139. cerr << "\n";
  140. }
  141. for ( i=0; i<argc; i++ ) {
  142. delete ptr_array[i];
  143. }
  144. delete ptr_array;
  145. return 0;
  146. }
  147. void dump_node_ids(info_base* x_base)
  148. {
  149. if ( x_base == 0 )
  150. return;
  151. int docs = x_base -> num_of_docs();
  152. doc_smart_ptr* doc = 0;
  153. node_smart_ptr* first_node = 0, *node = 0;
  154. dlp_smart_ptr* x = 0, *dlp_cell = 0;
  155. for ( int i=0; i<docs; i++ ) {
  156. doc = new doc_smart_ptr(x_base, i+1);
  157. debug(cerr, doc -> long_title());
  158. first_node = new node_smart_ptr(x_base, doc -> locator_id());
  159. dlp_cell = new dlp_smart_ptr(x_base, first_node -> its_oid());
  160. while ( dlp_cell ) {
  161. debug(cerr, dlp_cell -> node_id());
  162. x = dlp_cell -> next();
  163. delete dlp_cell;
  164. dlp_cell = x;
  165. }
  166. delete doc;
  167. delete first_node;
  168. }
  169. }
  170. #endif
  171. #ifdef REGRESSION_TEST
  172. #define TEST_STY_FILE "test.sty"
  173. #define TEST_SEC_FILE "test.sec"
  174. #define TEST_MIX_FILE "test.mix"
  175. int generate_stream(info_base* b_ptr, char* path, int num_sections, int min, int max)
  176. {
  177. random_gen x;
  178. if ( check_and_create_dir(path) == false )
  179. return -1;
  180. // generate stylesheet stream
  181. cerr << " stylesheets ..." << endl;
  182. int stylesheets = x.pick_a_value(5, 20); // assume [5, 20] is the range
  183. char buf[BUFSIZ];
  184. snprintf(buf, sizeof(buf), "%s/%s", path, TEST_STY_FILE);
  185. fstream stylesheet_stream(buf, ios::out);
  186. if ( !stylesheet_stream )
  187. return -1;
  188. int i;
  189. for (i=0; i<stylesheets; i++ ) {
  190. // assume the stylesheet and section are of approx. length
  191. generate_stylesheet_instance(x, stylesheet_stream, min, max);
  192. }
  193. // generate section stream
  194. cerr << " sections ..." << endl;
  195. snprintf(buf, sizeof(buf), "%s/%s", path, TEST_SEC_FILE);
  196. fstream section_stream(buf, ios::out);
  197. if ( !section_stream ) return -1;
  198. // prepare mixed stream
  199. snprintf(buf, sizeof(buf), "%s/%s", path, TEST_MIX_FILE);
  200. fstream mix_stream(buf, ios::out);
  201. if ( !mix_stream ) return -1;
  202. for (i=0; i<num_sections; i++ )
  203. generate_node_instance(b_ptr, x, section_stream, mix_stream, min, max);
  204. // generate mixed stream
  205. cerr << " docs ..." << endl;
  206. // doc
  207. int docs = x.pick_a_value(num_sections/4, num_sections/2);
  208. for (i=0; i<docs; i++ ) {
  209. // [docs/10, docs] is for the number of tab sections
  210. //generate_doc_instance(x, mix_stream, i+1, docs/10, docs);
  211. generate_doc_instance(x, mix_stream, i+1, 1, 10);
  212. }
  213. // toc
  214. cerr << " tocs ..." << endl;
  215. int tocs = docs;
  216. for (i=0; i<tocs; i++ ) {
  217. // [0, num_sections/10] is for the branch factor
  218. generate_toc_instance(x, mix_stream, i, 0, num_sections/10);
  219. }
  220. // sgml
  221. // graphic
  222. cerr << " graphics ..." << endl;
  223. int graphics = x.pick_a_value(num_sections/2, 2*num_sections);
  224. for (i=0; i<graphics; i++ )
  225. generate_graphic_instance(b_ptr, x, mix_stream, min, max);
  226. // locators
  227. cerr << " locators ..." << endl;
  228. int locs = x.pick_a_value(num_sections, num_sections*5);
  229. for (i=0; i<locs; i++ )
  230. generate_loc_instance(x, mix_stream);
  231. return 0;
  232. }
  233. int destroy_stream(char* path)
  234. {
  235. mtry {
  236. del_file(TEST_STY_FILE, path);
  237. del_file(TEST_SEC_FILE, path);
  238. del_file(TEST_MIX_FILE, path);
  239. }
  240. mcatch_any()
  241. {
  242. return -1;
  243. }
  244. end_try;
  245. return 0;
  246. }
  247. int extract_and_compare_objects(istream& in, info_base* base_ptr, int code)
  248. {
  249. int ok = 0;
  250. handler* root_hd_ptr = 0;
  251. vm_storage st((char*)"", (char*)"");
  252. char ccode_buf[LBUFSIZ];
  253. int c;
  254. while ( (c = in.get()) != EOF ) {
  255. in.putback(c);
  256. in.getline(ccode_buf, LBUFSIZ);
  257. sscanf(ccode_buf, "%u", &c);
  258. //debug(cerr, c);
  259. //fprintf(stderr, "code = %d\n", c);
  260. if ( c == SGML_CONTENT_CODE ) {
  261. if ( code == c || code == 0 )
  262. ok |= compare_SGML_content(in, base_ptr, (Boolean)true);
  263. else
  264. compare_SGML_content(in, base_ptr, (Boolean)false);
  265. } else {
  266. root_hd_ptr = new handler(c, &st);
  267. (*root_hd_ptr) -> asciiIn(in);
  268. if ( code == c || code == 0 ) {
  269. switch ( c ) {
  270. case OLIAS_NODE_CODE :
  271. ok |= compare_node(*(node_smart_ptr*)root_hd_ptr, base_ptr);
  272. break;
  273. case STYLESHEET_CODE :
  274. ok |= compare_stylesheet(*(stylesheet_smart_ptr*)root_hd_ptr, base_ptr);
  275. break;
  276. case DOC_CODE :
  277. ok |= compare_doc(*(doc_smart_ptr*)root_hd_ptr, base_ptr);
  278. break;
  279. case GRAPHIC_CODE :
  280. ok |= compare_graphic(*(graphic_smart_ptr*)root_hd_ptr, base_ptr);
  281. break;
  282. case TOC_CODE :
  283. ok |= compare_toc(*(toc_smart_ptr*)root_hd_ptr, base_ptr);
  284. break;
  285. case LOCATOR_CODE :
  286. ok |= compare_locator(*(locator_smart_ptr*)root_hd_ptr, base_ptr);
  287. break;
  288. default:
  289. break;
  290. }
  291. }
  292. delete root_hd_ptr;
  293. }
  294. st.remove();
  295. }
  296. return ok;
  297. }
  298. struct {
  299. char* name;
  300. c_code_t code;
  301. } auto_test_spec[] =
  302. {
  303. {(char*)"auto_node_test", OLIAS_NODE_CODE},
  304. {(char*)"auto_SGML_content_test", SGML_CONTENT_CODE},
  305. {(char*)"auto_stylesheet_test", STYLESHEET_CODE},
  306. {(char*)"auto_graphic_test", GRAPHIC_CODE},
  307. {(char*)"auto_doc_test", DOC_CODE},
  308. {(char*)"auto_toc_test", TOC_CODE},
  309. {(char*)"auto_loc_test", LOCATOR_CODE},
  310. };
  311. #define NUM_OF_AUTO_TESTS 7
  312. int auto_test(int argc, char** argv, OLIAS_DB& db)
  313. {
  314. int ok = 0;
  315. info_lib* infolib_ptr = db.openInfoLib(argv[2]);
  316. // define
  317. if ( infolib_ptr == 0 ||
  318. infolib_ptr->define_info_base(argv[4],argv[4],argv[3]) == false
  319. ) {
  320. STDERR_MESSAGE("creating test database failed\n");
  321. return -1;
  322. } else
  323. STDERR_MESSAGE("creating test database done\n");
  324. db.closeInfoLib(infolib_ptr->get_info_lib_uid());
  325. // randomly generate raw stream
  326. infolib_ptr = db.openInfoLib(argv[2]);
  327. info_base* base_ptr = infolib_ptr -> get_info_base(argv[4]);
  328. ok = generate_stream(base_ptr, argv[2],
  329. atoi(argv[5]), atoi(argv[6]), atoi(argv[7])
  330. );
  331. if ( ok != 0 ) {
  332. STDERR_MESSAGE("generating test data failed\n");
  333. return -1;
  334. } else
  335. STDERR_MESSAGE("generating test data done\n");
  336. db.closeInfoLib(infolib_ptr->get_info_lib_uid());
  337. // load style sheet
  338. cerr << " loading stylesheets ..." << endl;
  339. char buf[256];
  340. char file_name[256];
  341. snprintf(buf, sizeof(buf), "%s.stylesheet", argv[4]);
  342. snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_STY_FILE);
  343. infolib_ptr = db.openInfoLib(argv[2]);
  344. base_ptr = infolib_ptr -> get_info_base(argv[4]);
  345. ok = load( base_ptr, buf, file_name );
  346. if ( ok != 0 ) {
  347. STDERR_MESSAGE("loading test stylesheet data failed\n");
  348. return -1;
  349. } else
  350. STDERR_MESSAGE("loading test stylesheet data done\n");
  351. db.closeInfoLib(infolib_ptr->get_info_lib_uid());
  352. // load sections (small component)
  353. cerr << " loading sections ..." << endl;
  354. snprintf(buf, sizeof(buf), "%s.node", argv[4]);
  355. snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_SEC_FILE);
  356. infolib_ptr = db.openInfoLib(argv[2]);
  357. base_ptr = infolib_ptr -> get_info_base(argv[4]);
  358. ok = load( base_ptr, buf, file_name );
  359. if ( ok != 0 ) {
  360. STDERR_MESSAGE("loading test section data failed\n");
  361. return -1;
  362. } else
  363. STDERR_MESSAGE("loading test section data done\n");
  364. db.closeInfoLib(infolib_ptr->get_info_lib_uid());
  365. // load all other objects
  366. cerr << " loading all other objects ..." << endl;
  367. snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_MIX_FILE);
  368. fstream in(file_name, ios::in);
  369. if ( !in ) return -1;
  370. infolib_ptr = db.openInfoLib(argv[2]);
  371. base_ptr = infolib_ptr -> get_info_base(argv[4]);
  372. ok = _load_mixed_objects(base_ptr, in);
  373. if ( ok != 0 ) {
  374. STDERR_MESSAGE("loading all other test data failed\n");
  375. return -1;
  376. } else
  377. STDERR_MESSAGE("loading all other test data done\n");
  378. db.closeInfoLib(infolib_ptr->get_info_lib_uid());
  379. // test
  380. infolib_ptr = db.openInfoLib(argv[2]);
  381. base_ptr = infolib_ptr -> get_info_base(argv[4]);
  382. // stylesheet
  383. snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_STY_FILE);
  384. fstream ss_in(file_name, ios::in);
  385. if ( !ss_in ) return -1;
  386. ok = extract_and_compare_objects(ss_in, base_ptr, 0);
  387. if ( ok != 0 ) {
  388. STDERR_MESSAGE("testing stylesheet data failed\n");
  389. return -1;
  390. } else
  391. STDERR_MESSAGE("testing stylesheet data done\n");
  392. // node
  393. snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_SEC_FILE);
  394. fstream nd_in(file_name, ios::in);
  395. if ( !nd_in ) return -1;
  396. ok = extract_and_compare_objects(nd_in, base_ptr, 0);
  397. if ( ok != 0 ) {
  398. STDERR_MESSAGE("testing section failed\n");
  399. return -1;
  400. } else
  401. STDERR_MESSAGE("testing section done\n");
  402. // all other
  403. snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_MIX_FILE);
  404. fstream all_in(file_name, ios::in);
  405. if ( !all_in ) return -1;
  406. ok = extract_and_compare_objects(all_in, base_ptr, 0);
  407. if ( ok != 0 ) {
  408. STDERR_MESSAGE("testing all other data failed\n");
  409. return -1;
  410. } else
  411. STDERR_MESSAGE("testing all other data done\n");
  412. db.closeInfoLib(infolib_ptr->get_info_lib_uid());
  413. if ( argc == 8 ||
  414. ( argc == 9 && strcmp(argv[8], "true") == 0 ) )
  415. {
  416. db.destroy(argv[2]);
  417. destroy_stream(argv[2]);
  418. }
  419. return ok;
  420. }
  421. #endif
  422. int select_debug_routine(int argc, char** argv, OLIAS_DB& db)
  423. {
  424. int ok = 2;
  425. #ifdef REGRESSION_TEST
  426. if ( strcmp(argv[1], "auto_test") == 0 ) {
  427. if (argc != 8 && argc != 9 ) {
  428. // 1 2 3 4 5
  429. cerr << "usage: auto_test info_lib_path info_base_spec base_name number_of_sections max_section_size, min_section_size [true|false]\n";
  430. return 1;
  431. } else
  432. return auto_test(argc, argv, db);
  433. }
  434. ok =store_test(argc, argv);
  435. if ( ok != 2 ) {
  436. return ok;
  437. }
  438. ok =dstr_test(argc, argv);
  439. if ( ok != 2 ) {
  440. return ok;
  441. }
  442. ok =mark_test(argc, argv);
  443. #ifdef NODEBUG
  444. if (ok < 0) {
  445. cerr << "mark_test failed." << endl;
  446. return ok;
  447. }
  448. else
  449. cerr << "mark_test done." << endl;
  450. #else
  451. if ( ok != 2 ) {
  452. return ok;
  453. }
  454. #endif
  455. for ( int i=0; i<NUM_OF_AUTO_TESTS; i++ )
  456. if ( strcmp(argv[1], auto_test_spec[i].name) == 0 ) {
  457. if ( argc != 4 && argc != 3 ) {
  458. cerr << " args: " << auto_test_spec[i].name ;
  459. cerr << " base_name [stream_file_name]";
  460. return 1;
  461. }
  462. info_base* base_ptr = db.openInfoLib() -> get_info_base(argv[2]);
  463. if ( argc == 4 ) {
  464. fstream in(argv[3], ios::in);
  465. return extract_and_compare_objects(in, base_ptr, auto_test_spec[i].code);
  466. } else {
  467. return extract_and_compare_objects(cin, base_ptr, auto_test_spec[i].code);
  468. }
  469. }
  470. #endif
  471. #ifdef NODEBUG
  472. if ( strcmp(argv[1], "random_gen") == 0 ) {
  473. if ( argc != 7 ) {
  474. cerr << "random_gen args: " << "random_gen base_name path num_sections min_section_len max_sec_len\n";
  475. return 1;
  476. }
  477. info_base* base_ptr = db.openInfoLib() -> get_info_base(argv[2]);
  478. return generate_stream(base_ptr, argv[3], atoi(argv[4]), atoi(argv[5]), atoi(argv[6]));
  479. } else
  480. if ( strcmp(argv[1], "test_iterator") == 0 ) {
  481. info_base* base_ptr = db.openInfoLib() -> get_info_base(argv[2]);
  482. test_collector_iterator(base_ptr);
  483. ok = 0;
  484. } else
  485. if ( strcmp(argv[1], "dump_node_ids") == 0 ) {
  486. if ( argc != 3 ) {
  487. MESSAGE(cerr, "dump_node_ids args: dump_node_ids base_nm");
  488. } else {
  489. info_base* base_ptr = db.openInfoLib() -> get_info_base(argv[2]);
  490. dump_node_ids(base_ptr);
  491. ok = 0;
  492. }
  493. } else
  494. if ( strcmp(argv[1], "dump_instances") == 0 ) {
  495. if ( argc != 4 ) {
  496. MESSAGE(cerr, "load args: dump_all_instance base_nm type");
  497. } else {
  498. info_base* base_ptr = db.openInfoLib() -> get_info_base(argv[2]);
  499. if ( strcmp(argv[3], "nodes") == 0 )
  500. ok = dump_instances(base_ptr, NODE_SET_NAME, OLIAS_NODE_CODE);
  501. else
  502. if ( strcmp(argv[3], "locators") == 0 )
  503. ok = dump_instances(base_ptr, LOCATOR_SET_NAME, LOCATOR_CODE);
  504. else
  505. if ( strcmp(argv[3], "graphics") == 0 )
  506. ok = dump_instances(base_ptr, GRAPHIC_SET_NAME, GRAPHIC_CODE);
  507. }
  508. } else
  509. if ( strcmp(argv[1], "file_load") == 0 ) {
  510. if ( (argc-2) % 3 != 0 ) {
  511. MESSAGE(cerr,
  512. "load args: file_load [obj_type obj_name data_file]+");
  513. } else {
  514. info_base* base_ptr = db.openInfoLib() -> get_info_base(argv[2]);
  515. ok = load( base_ptr, argv+2, argc-2 );
  516. }
  517. } else
  518. if ( strcmp(argv[1], "loc_test") == 0 ) {
  519. if ( argc != 4 ) {
  520. MESSAGE(cerr,
  521. "loc_test args: loc_test base_name loc_value");
  522. } else {
  523. ok = loc_test( db.openInfoLib(), argv[2], argv[3] );
  524. }
  525. } else
  526. if ( strcmp(argv[1], "toc_test") == 0 ) {
  527. if ( argc != 4 ) {
  528. MESSAGE(cerr,
  529. "toc_test args: toc_test base_name oid_str");
  530. } else {
  531. ok = toc_test( db.openInfoLib(), argv[2], argv[3] );
  532. }
  533. } else
  534. if ( strcmp(argv[1], "graphic_test") == 0 ) {
  535. if ( argc != 4 ) {
  536. MESSAGE(cerr,
  537. "graphic_test args: graphic_test base_name oid_str");
  538. } else {
  539. ok = graphic_test( db.openInfoLib(), argv[2], argv[3] );
  540. }
  541. } else
  542. if ( strcmp(argv[1], "stylesheet_test_loc") == 0 ) {
  543. if ( argc != 4 ) {
  544. MESSAGE(cerr,
  545. "stylesheet_test_loc args: stylesheet_test_loc base_name loc");
  546. } else {
  547. ok = stylesheet_test_loc( db.openInfoLib(), argv[2], argv[3] );
  548. }
  549. } else
  550. if ( strcmp(argv[1], "stylesheet_test_oid") == 0 ) {
  551. if ( argc != 4 ) {
  552. MESSAGE(cerr,
  553. "stylesheet_test_oid args: stylesheet_test_oid base_name oid");
  554. } else {
  555. ok = stylesheet_test_oid( db.openInfoLib(), argv[2], argv[3] );
  556. }
  557. } else
  558. if ( strcmp(argv[1], "node_test_loc") == 0 ) {
  559. if ( argc != 4 ) {
  560. MESSAGE(cerr,
  561. "node_test_loc args: node_test_loc base_name loc");
  562. } else {
  563. ok = node_test_loc( db.openInfoLib(), argv[2], argv[3] );
  564. }
  565. } else
  566. if ( strcmp(argv[1], "node_test_oid") == 0 ) {
  567. if ( argc != 4 ) {
  568. MESSAGE(cerr,
  569. "node_test_oid args: node_test_oid base_name oid_str");
  570. } else {
  571. ok = node_test_oid( db.openInfoLib(), argv[2], argv[3] );
  572. }
  573. } else
  574. if ( strcmp(argv[1], "dlp_test") == 0 ) {
  575. if ( argc != 4 ) {
  576. MESSAGE(cerr,
  577. "dlp_test args: dlp_test base_name oid_str");
  578. } else {
  579. ok = dlp_test( db.openInfoLib(), argv[2], argv[3] );
  580. }
  581. } else
  582. if ( strcmp(argv[1], "doc_test_oid") == 0 ) {
  583. if ( argc != 4 ) {
  584. MESSAGE(cerr,
  585. "doc_test_oid args: doc_test_oid base_name oid_str");
  586. } else {
  587. ok = doc_test_oid( db.openInfoLib(), argv[2], argv[3] );
  588. }
  589. } else
  590. if ( strcmp(argv[1], "doc_test_int") == 0 ) {
  591. if ( argc != 4 ) {
  592. MESSAGE(cerr,
  593. "doc_test_int args: doc_test_int base_name int_str");
  594. } else {
  595. ok = doc_test_int( db.openInfoLib(), argv[2], argv[3] );
  596. }
  597. }
  598. #endif
  599. return ok;
  600. }