parse.tests 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #!/bin/sh
  2. # Copyright 2008 by Denys Vlasenko <vda.linux@googlemail.com>
  3. # Licensed under GPL v2, see file LICENSE for details.
  4. . ./testing.sh
  5. COLLAPSE=$(( 0x00010000))
  6. TRIM=$(( 0x00020000))
  7. GREEDY=$(( 0x00040000))
  8. MIN_DIE=$(( 0x00100000))
  9. KEEP_COPY=$((0x00200000))
  10. ESCAPE=$(( 0x00400000))
  11. NORMAL=$(( COLLAPSE | TRIM | GREEDY))
  12. # testing "description" "command" "result" "infile" "stdin"
  13. testing "parse mdev.conf" \
  14. "parse -n 4 -m 3 -f $((NORMAL)) -" \
  15. "[sda][0:0][644][@echo @echo TEST]\n" \
  16. "-" \
  17. " sda 0:0 644 @echo @echo TEST # echo trap\n"
  18. testing "parse notrim" \
  19. "parse -n 4 -m 3 -f $((NORMAL - TRIM - COLLAPSE)) -" \
  20. "[][sda][0:0][644 @echo @echo TEST ]\n" \
  21. "-" \
  22. " sda 0:0 644 @echo @echo TEST \n"
  23. FILE=__parse
  24. cat >$FILE <<EOF
  25. #
  26. # Device Point System Options
  27. #_______________________________________________________________
  28. /dev/hdb3 / ext2 defaults 1 0
  29. /dev/hdb1 /dosc hpfs ro 1 0
  30. /dev/fd0 /dosa vfat rw,user,noauto,nohide 0 0
  31. /dev/fd1 /dosb vfat rw,user,noauto,nohide 0 0
  32. #
  33. /dev/cdrom /cdrom iso9660 ro,user,noauto,nohide 0 0
  34. /dev/hdb5 /redhat ext2 rw,root,noauto,nohide 0 0 #sssd
  35. /dev/hdb6 /win2home ntfs rw,root,noauto,nohide 0 0# ssdsd
  36. /dev/hdb7 /win2skul ntfs rw,root,noauto,nohide none 0 0
  37. none /dev/pts devpts gid=5,mode=620 0 0
  38. none /proc proc defaults 0 0
  39. EOF
  40. cat >$FILE.res <<EOF
  41. [/dev/hdb3][/][ext2][defaults][1][0]
  42. [/dev/hdb1][/dosc][hpfs][ro][1][0]
  43. [/dev/fd0][/dosa][vfat][rw,user,noauto,nohide][0][0]
  44. [/dev/fd1][/dosb][vfat][rw,user,noauto,nohide][0][0]
  45. [/dev/cdrom][/cdrom][iso9660][ro,user,noauto,nohide][0][0]
  46. [/dev/hdb5][/redhat][ext2][rw,root,noauto,nohide][0][0]
  47. [/dev/hdb6][/win2home][ntfs][rw,root,noauto,nohide][0][0]
  48. [/dev/hdb7][/win2skul][ntfs][rw,root,noauto,nohide][none][0 0]
  49. [none][/dev/pts][devpts][gid=5,mode=620][0][0]
  50. [none][/proc][proc][defaults][0][0]
  51. EOF
  52. testing "parse polluted fstab" \
  53. "parse -n 6 -m 6 $FILE" \
  54. "`cat $FILE.res`\n" \
  55. "" \
  56. ""
  57. cp ../examples/inittab $FILE
  58. cat >$FILE.res <<EOF
  59. [][][sysinit][/etc/init.d/rcS]
  60. [][][askfirst][-/bin/sh]
  61. [tty2][][askfirst][-/bin/sh]
  62. [tty3][][askfirst][-/bin/sh]
  63. [tty4][][askfirst][-/bin/sh]
  64. [tty4][][respawn][/sbin/getty 38400 tty5]
  65. [tty5][][respawn][/sbin/getty 38400 tty6]
  66. [][][restart][/sbin/init]
  67. [][][ctrlaltdel][/sbin/reboot]
  68. [][][shutdown][/bin/umount -a -r]
  69. [][][shutdown][/sbin/swapoff -a]
  70. EOF
  71. testing "parse inittab from examples" \
  72. "parse -n 4 -m 4 -f $((NORMAL - TRIM - COLLAPSE)) -d'#:' $FILE" \
  73. "`cat $FILE.res`\n" \
  74. "" \
  75. ""
  76. cp ../examples/udhcp/udhcpd.conf $FILE
  77. cat >$FILE.res <<EOF
  78. [start][192.168.0.20]
  79. [end][192.168.0.254]
  80. [interface][eth0]
  81. [opt][dns][192.168.10.2][192.168.10.10]
  82. [option][subnet][255.255.255.0]
  83. [opt][router][192.168.10.2]
  84. [opt][wins][192.168.10.10]
  85. [option][dns][129.219.13.81]
  86. [option][domain][local]
  87. [option][lease][864000]
  88. EOF
  89. testing "parse udhcpd.conf from examples" \
  90. "parse -n 127 $FILE" \
  91. "`cat $FILE.res`\n" \
  92. "" \
  93. ""
  94. rm -f $FILE $FILE.res
  95. exit $FAILCOUNT