Debian Codegraph @

debian/tests/run-unit-test

raw
1 #!/bin/sh
2
3 # Author: Lance Lin <[email protected]>
4 # Date: 20 December 2021
5 # File: run-unit-test
6 # Purpose: run a simple-unit test for the fsm-lite package
7 #
8 # Details:
9 # Use a publicly accessible .fasta file format example. There are others, but they quite large (>30MB)
10 #
11 # Execute fsm-lite on the sample data and verify the resulting generated files are the correct length
12 #
13 # Verify the two ouptut is correct:
14 # tmp.meta should look like: "testfile 1508 ", which is {inputFileName, filesize}
15 # tmp.tmp will have the sequencing and should be 1508 bytes in length, as reported by tmp.meta
16
17 set -e
18
19 if [ "${AUTOPKGTEST_TMP}" = "" ] ; then
20 AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
21 trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
22 fi
23 cd "${AUTOPKGTEST_TMP}"
24
25 echo "run-unit-test: generating data"
26
27 # FASTA format file from "UT Southwestern Medical Center"
28 # URL: http://prodata.swmed.edu/promals/info/fasta_format_file_example.htm
29 # Website title: Fasta format file example
30 # Date accessed: 20 December 2021
31 cat <<EOF > testfile.fasta
32 >seq0
33 FQTWEEFSRAAEKLYLADPMKVRVVLKYRHVDGNLCIKVTDDLVCLVYRTDQAQDVKKIEKF
34 >seq1
35 KYRTWEEFTRAAEKLYQADPMKVRVVLKYRHCDGNLCIKVTDDVVCLLYRTDQAQDVKKIEKFHSQLMRLME LKVTDNKECLKFKTDQAQEAKKMEKLNNIFFTLM
36 >seq2
37 EEYQTWEEFARAAEKLYLTDPMKVRVVLKYRHCDGNLCMKVTDDAVCLQYKTDQAQDVKKVEKLHGK
38 >seq3
39 MYQVWEEFSRAVEKLYLTDPMKVRVVLKYRHCDGNLCIKVTDNSVCLQYKTDQAQDVK
40 >seq4
41 EEFSRAVEKLYLTDPMKVRVVLKYRHCDGNLCIKVTDNSVVSYEMRLFGVQKDNFALEHSLL
42 >seq5
43 SWEEFAKAAEVLYLEDPMKCRMCTKYRHVDHKLVVKLTDNHTVLKYVTDMAQDVKKIEKLTTLLMR
44 >seq6
45 FTNWEEFAKAAERLHSANPEKCRFVTKYNHTKGELVLKLTDDVVCLQYSTNQLQDVKKLEKLSSTLLRSI
46 >seq7
47 SWEEFVERSVQLFRGDPNATRYVMKYRHCEGKLVLKVTDDRECLKFKTDQAQDAKKMEKLNNIFF
48 >seq8
49 SWDEFVDRSVQLFRADPESTRYVMKYRHCDGKLVLKVTDNKECLKFKTDQAQEAKKMEKLNNIFFTLM
50 >seq9
51 KNWEDFEIAAENMYMANPQNCRYTMKYVHSKGHILLKMSDNVKCVQYRAENMPDLKK
52 >seq10
53 FDSWDEFVSKSVELFRNHPDTTRYVVKYRHCEGKLVLKVTDNHECLKFKTDQAQDAKKMEK
54 EOF
55
56
57 echo "run-unit-test: generating test input list file"
58 cat <<EOF > input.list
59 testfile ${AUTOPKGTEST_TMP}/testfile.fasta
60 EOF
61
62 echo "run-unit-test: generating md5 sums for verification"
63 echo "001b2030f247b79c4339a3a4d4b3438c tmp.meta" >> checksums
64 echo "19f8e2431c735a5f86e60251a80b37f4 tmp.tmp" >> checksums
65
66 echo "run-unit-test: running fsm-lite"
67 fsm-lite -l input.list -t tmp | gzip - > output.txt.gz
68
69 echo "run-unit-test: verifying md5 checksums"
70 md5sum --check checksums
71
72 echo "run-unit-test: verifying output"
73
74 # Output in tmp.meta should contain "1508", the file size/output of tmp.tmp in bytes
75 # The test will capture the file size from tmp.meta and compare the output file length
76 fileSizeMeta=$(cat tmp.meta | cut -f2)
77
78 # Check file size of tmp.tmp matches what is reported by tmp.meta
79 fileSize=$(du -b tmp.tmp | cut -f1)
80
81 if [ ${fileSize} -ne ${fileSizeMeta} ]
82 then
83 echo "run-unit-test: Failure - output file size does not match expected: $fileSize (generated) instead of $fileSizeMeta (expected)"
84 exit 1
85 fi