You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

496 lines
9.3 KiB

  1. #!/usr/bin/env perl
  2. #
  3. # A driver program to test DBUG features - runs tests (shell commands)
  4. # from the end of file to invoke tests.c, which does the real dbug work.
  5. #
  6. use Test::More;
  7. $exe=$0;
  8. die unless $exe =~ s/(tests)-t(\.exe)?$/$1$2 /;
  9. # load tests
  10. @tests=();
  11. while (<DATA>) {
  12. if (/^% \.\/tests /) {
  13. push @tests, [ $' ]
  14. } elsif (/^#/) {
  15. next;
  16. } else {
  17. push @{$tests[$#tests]}, $_
  18. }
  19. }
  20. plan skip_all => "because dbug is disabled" if system $exe;
  21. plan tests => scalar(@tests);
  22. for (@tests) {
  23. $t=$exe . shift @$_;
  24. chomp($t);
  25. open F, '-|', $t or die "open($t|): $!";
  26. local $";
  27. $out=join($", <F>); close(F);
  28. # special cases are handled here:
  29. $out =~ s/Memory: 0x[0-9A-Fa-f]+/Memory: 0x####/g if $t =~ /dump/;
  30. # compare ("\n" at the beginning makes better output in case of errors)
  31. is("\n$out","\n@$_", $t);
  32. }
  33. __DATA__
  34. % ./tests -#d
  35. func2: info: s=ok
  36. => execute
  37. => evaluate: ON
  38. => evaluate_if: OFF
  39. main: explain: dbug explained: d
  40. func2: info: s=ok
  41. % ./tests d,ret3
  42. => evaluate: OFF
  43. => evaluate_if: OFF
  44. #
  45. ## Testing negative lists
  46. #
  47. % ./tests d:-d,ret3
  48. func2: info: s=ko
  49. => execute
  50. => evaluate: ON
  51. => evaluate_if: OFF
  52. main: explain: dbug explained: d:-d,ret3
  53. func2: info: s=ko
  54. % ./tests t:-d,ret3
  55. >main
  56. | >func1
  57. | | >func2
  58. | | | >func3
  59. | | | <func3
  60. | | <func2
  61. | <func1
  62. => evaluate: OFF
  63. => evaluate_if: OFF
  64. | >func2
  65. | | >func3
  66. | | <func3
  67. | <func2
  68. <main
  69. % ./tests t:d,info:-d,ret3
  70. >main
  71. | >func1
  72. | | >func2
  73. | | | >func3
  74. | | | <func3
  75. | | | info: s=ko
  76. | | <func2
  77. | <func1
  78. => evaluate: OFF
  79. => evaluate_if: OFF
  80. | >func2
  81. | | >func3
  82. | | <func3
  83. | | info: s=ko
  84. | <func2
  85. <main
  86. % ./tests t:d,info:-d,ret3:-f,func2
  87. >main
  88. | >func1
  89. | | | >func3
  90. | | | <func3
  91. | <func1
  92. => evaluate: OFF
  93. => evaluate_if: OFF
  94. | | >func3
  95. | | <func3
  96. <main
  97. % ./tests t:d,info:-d,ret3:-f,func2 d,evaluate
  98. => evaluate: ON
  99. => evaluate_if: OFF
  100. % ./tests t:d,info:-d,ret3:-f,func2 d,evaluate_if
  101. => evaluate: OFF
  102. => evaluate_if: ON
  103. % ./tests t:d:-d,ret3:-f,func2 d,evaluate_if
  104. => evaluate: OFF
  105. => evaluate_if: ON
  106. % ./tests t:d:-d,ret3:-f,func2
  107. >main
  108. | >func1
  109. | | | >func3
  110. | | | <func3
  111. | <func1
  112. => execute
  113. => evaluate: ON
  114. => evaluate_if: OFF
  115. | explain: dbug explained: d:-d,ret3:f:-f,func2:t
  116. | | >func3
  117. | | <func3
  118. <main
  119. #
  120. ## Adding incremental settings to the brew
  121. #
  122. % ./tests t:d:-d,ret3:-f,func2 +d,evaluate_if
  123. >main
  124. | >func1
  125. | | | >func3
  126. | | | <func3
  127. | <func1
  128. => evaluate: OFF
  129. => evaluate_if: ON
  130. | | >func3
  131. | | <func3
  132. <main
  133. #
  134. ## DBUG_DUMP
  135. #
  136. % ./tests t:d:-d,ret3:f:-f,func2 +d,dump
  137. >main
  138. | >func1
  139. | | | >func3
  140. | | | <func3
  141. | <func1
  142. | dump: Memory: 0x#### Bytes: (27)
  143. 64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A
  144. 74
  145. => evaluate: OFF
  146. => evaluate_if: OFF
  147. | | >func3
  148. | | <func3
  149. <main
  150. % ./tests t:d:-d,ret3:f:-f,func2 +d,dump
  151. >main
  152. | >func1
  153. | | | >func3
  154. | | | <func3
  155. | <func1
  156. | dump: Memory: 0x#### Bytes: (27)
  157. 64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A
  158. 74
  159. => evaluate: OFF
  160. => evaluate_if: OFF
  161. | | >func3
  162. | | <func3
  163. <main
  164. % ./tests t:d:-d,ret3:f:-f,func2:+d,dump
  165. >main
  166. | >func1
  167. | | | >func3
  168. | | | <func3
  169. | <func1
  170. | dump: Memory: 0x#### Bytes: (27)
  171. 64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A
  172. 74
  173. => evaluate: OFF
  174. => evaluate_if: OFF
  175. | | >func3
  176. | | <func3
  177. <main
  178. % ./tests t:d:-d,ret3:f:-f,func2 +d,dump,explain
  179. >main
  180. | >func1
  181. | | | >func3
  182. | | | <func3
  183. | <func1
  184. | dump: Memory: 0x#### Bytes: (35)
  185. 64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D
  186. 66 2C 66 75 6E 63 32 3A 74
  187. => evaluate: OFF
  188. => evaluate_if: OFF
  189. | explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:t
  190. | | >func3
  191. | | <func3
  192. <main
  193. % ./tests t:d:-d,ret3:f:-f,func2 +d,dump,explain:P
  194. dbug: >main
  195. dbug-tests: | >func1
  196. dbug-tests: | | | >func3
  197. dbug-tests: | | | <func3
  198. dbug-tests: | <func1
  199. dbug-tests: | dump: Memory: 0x#### Bytes: (37)
  200. 64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D
  201. 66 2C 66 75 6E 63 32 3A 50 3A 74
  202. => evaluate: OFF
  203. => evaluate_if: OFF
  204. dbug-tests: | explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:P:t
  205. dbug-tests: | | >func3
  206. dbug-tests: | | <func3
  207. dbug-tests: <main
  208. % ./tests t:d:-d,ret3:f:-f,func2 +d,dump,explain:P:F
  209. dbug: tests.c: >main
  210. dbug-tests: tests.c: | >func1
  211. dbug-tests: tests.c: | | | >func3
  212. dbug-tests: tests.c: | | | <func3
  213. dbug-tests: tests.c: | <func1
  214. dbug-tests: tests.c: | dump: Memory: 0x#### Bytes: (39)
  215. 64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D
  216. 66 2C 66 75 6E 63 32 3A 46 3A 50 3A 74
  217. => evaluate: OFF
  218. => evaluate_if: OFF
  219. dbug-tests: tests.c: | explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:F:P:t
  220. dbug-tests: tests.c: | | >func3
  221. dbug-tests: tests.c: | | <func3
  222. dbug-tests: tests.c: <main
  223. #
  224. ## DBUG_EXPLAIN, DBUG_PUSH, DBUG_POP, DBUG_SET
  225. #
  226. % ./tests t:d:-d,ret3:f:-f,func2
  227. >main
  228. | >func1
  229. | | | >func3
  230. | | | <func3
  231. | <func1
  232. => execute
  233. => evaluate: ON
  234. => evaluate_if: OFF
  235. | explain: dbug explained: d:-d,ret3:f:-f,func2:t
  236. | | >func3
  237. | | <func3
  238. <main
  239. % ./tests t:d:-d,ret3
  240. >main
  241. | >func1
  242. | | >func2
  243. | | | >func3
  244. | | | <func3
  245. | | | info: s=ko
  246. | | <func2
  247. | <func1
  248. => execute
  249. => evaluate: ON
  250. => evaluate_if: OFF
  251. | explain: dbug explained: d:-d,ret3:t
  252. | >func2
  253. | | >func3
  254. | | <func3
  255. | | info: s=ko
  256. | <func2
  257. <main
  258. % ./tests d,info:-d,ret3:d,push
  259. func2: info: s=ko
  260. => evaluate: OFF
  261. => evaluate_if: OFF
  262. | >func2
  263. | | >func3
  264. | | <func3
  265. | | info: s=ko
  266. | <func2
  267. <main
  268. % ./tests d,info:-d,ret3:d,push,explain
  269. func2: info: s=ko
  270. => evaluate: OFF
  271. => evaluate_if: OFF
  272. | explain: dbug explained: d,info,push,explain:-d,ret3:t
  273. | >func2
  274. | | >func3
  275. | | <func3
  276. | | info: s=ko
  277. | <func2
  278. <main
  279. % ./tests d,info:-d,ret3:d,explain
  280. func2: info: s=ko
  281. => evaluate: OFF
  282. => evaluate_if: OFF
  283. main: explain: dbug explained: d,info,explain:-d,ret3
  284. func2: info: s=ko
  285. % ./tests d,info:-d,ret3:d,explain,pop
  286. func2: info: s=ko
  287. => evaluate: OFF
  288. => evaluate_if: OFF
  289. % ./tests d,info:-d,ret3:d,explain t:d,pop
  290. >main
  291. | >func1
  292. | | >func2
  293. | | | >func3
  294. | | | <func3
  295. | | <func2
  296. | <func1
  297. => evaluate: OFF
  298. => evaluate_if: OFF
  299. main: explain: dbug explained: d,info,explain:-d,ret3
  300. func2: info: s=ko
  301. % ./tests d,info:-d,ret3:d,explain,pop +t
  302. >main
  303. | >func1
  304. | | >func2
  305. | | | >func3
  306. | | | <func3
  307. | | | info: s=ko
  308. | | <func2
  309. | <func1
  310. => evaluate: OFF
  311. => evaluate_if: OFF
  312. main: explain: dbug explained: d,info,explain,pop:-d,ret3
  313. func2: info: s=ko
  314. % ./tests d,info:-d,ret3:d,explain,set
  315. func2: info: s=ko
  316. => evaluate: OFF
  317. => evaluate_if: OFF
  318. tests.c: main: explain: dbug explained: d,info,explain,set:-d,ret3:F
  319. tests.c: func2: info: s=ko
  320. % ./tests d,info:-d,ret3:d,explain,set:t
  321. >main
  322. | >func1
  323. | | >func2
  324. | | | >func3
  325. | | | <func3
  326. | | | info: s=ko
  327. | | <func2
  328. | <func1
  329. => evaluate: OFF
  330. => evaluate_if: OFF
  331. tests.c: | explain: dbug explained: d,info,explain,set:-d,ret3:F:t
  332. tests.c: | >func2
  333. tests.c: | | >func3
  334. tests.c: | | <func3
  335. tests.c: | | info: s=ko
  336. tests.c: | <func2
  337. tests.c: <main
  338. % ./tests t d,info:-d,ret3:d,explain,set:t
  339. >main
  340. | >func1
  341. | | >func2
  342. | | | >func3
  343. | | | <func3
  344. | | | info: s=ko
  345. | | <func2
  346. | <func1
  347. => evaluate: OFF
  348. => evaluate_if: OFF
  349. tests.c: | explain: dbug explained: d,info,explain,set:-d,ret3:F:t
  350. tests.c: | >func2
  351. tests.c: | | >func3
  352. tests.c: | | <func3
  353. tests.c: | | info: s=ko
  354. tests.c: | <func2
  355. tests.c: <main
  356. % ./tests t d,info:-d,ret3:d,explain,set,pop
  357. func2: info: s=ko
  358. => evaluate: OFF
  359. => evaluate_if: OFF
  360. | >func2
  361. | | >func3
  362. | | <func3
  363. | <func2
  364. <main
  365. % ./tests t:f,func2
  366. | | >func2
  367. | | <func2
  368. => evaluate: OFF
  369. => evaluate_if: OFF
  370. | >func2
  371. | <func2
  372. #
  373. ## Testing SUBDIR rules
  374. #
  375. % ./tests t:-f,func2/:d
  376. >main
  377. | >func1
  378. | <func1
  379. => execute
  380. => evaluate: ON
  381. => evaluate_if: OFF
  382. | explain: dbug explained: d:f:-f,func2/:t
  383. <main
  384. % ./tests t:f,func1/:d
  385. | >func1
  386. | | >func2
  387. | | | >func3
  388. | | | <func3
  389. | | | info: s=ok
  390. | | <func2
  391. | <func1
  392. => evaluate: OFF
  393. => evaluate_if: OFF
  394. % ./tests t:f,main/:d,pop
  395. >main
  396. | >func1
  397. | | >func2
  398. | | | >func3
  399. | | | <func3
  400. | | <func2
  401. | <func1
  402. => evaluate: OFF
  403. => evaluate_if: OFF
  404. % ./tests f,main/:d,push
  405. => evaluate: OFF
  406. => evaluate_if: OFF
  407. | >func2
  408. | | >func3
  409. | | <func3
  410. | <func2
  411. <main
  412. #
  413. ## Testing FixTraceFlags() - when we need to traverse the call stack
  414. # (these tests fail with FixTraceFlags() disabled)
  415. #
  416. # delete the INCLUDE rule up the stack
  417. % ./tests t:f,func1/ --push1=t:f,func3/
  418. | >func1
  419. | | >func2
  420. | | | >func3
  421. | | | <func3
  422. | | <func2
  423. => push1
  424. => evaluate: OFF
  425. => evaluate_if: OFF
  426. | | >func3
  427. | | <func3
  428. # delete the EXCLUDE rule up the stack
  429. % ./tests t:-f,func1/ --push1=t
  430. >main
  431. => push1
  432. | <func1
  433. => evaluate: OFF
  434. => evaluate_if: OFF
  435. | >func2
  436. | | >func3
  437. | | <func3
  438. | <func2
  439. <main
  440. # add the INCLUDE rule up the stack
  441. % ./tests t:f,func3 --push1=t:f,main/
  442. | | | >func3
  443. | | | <func3
  444. => push1
  445. | <func1
  446. => evaluate: OFF
  447. => evaluate_if: OFF
  448. | >func2
  449. | | >func3
  450. | | <func3
  451. | <func2
  452. <main
  453. # add the EXCLUDE rule up the stack
  454. % ./tests t --push1=t:-f,main/
  455. >main
  456. | >func1
  457. | | >func2
  458. | | | >func3
  459. | | | <func3
  460. | | <func2
  461. => push1
  462. => evaluate: OFF
  463. => evaluate_if: OFF
  464. # change the defaults
  465. % ./tests t:f,func3 --push1=t
  466. | | | >func3
  467. | | | <func3
  468. => push1
  469. | <func1
  470. => evaluate: OFF
  471. => evaluate_if: OFF
  472. | >func2
  473. | | >func3
  474. | | <func3
  475. | <func2
  476. <main
  477. # repeated keyword
  478. % ./tests d:-d,info,info
  479. => execute
  480. => evaluate: ON
  481. => evaluate_if: OFF
  482. main: explain: dbug explained: d:-d,info
  483. % ./tests d:-d,info/,info
  484. => execute
  485. => evaluate: ON
  486. => evaluate_if: OFF
  487. main: explain: dbug explained: d:-d,info/