File: run_transform_test

package info (click to toggle)
frobby 0.9.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 11,616 kB
  • sloc: cpp: 30,134; sh: 1,184; makefile: 306; ansic: 102; lisp: 10
file content (96 lines) | stat: -rwxr-xr-x 3,356 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash

# Note that not specifying the input format tests the format
# autodetection. We first produce output in all formats with no other
# transformation, and we end with producing canonical output without
# specifying the output format.

testhelper=../testScripts/testhelper
frobby=../../bin/frobby
testName="$1"
shift

inputFile="$testName.test"
formats="m2 4ti2 monos newmonos singular cocoa4"

if [ "$testName" = "null" ]; then
  null="-iformat null"
fi

if [ "$1" = "_full" ];
then
  shift;

  # Inverting twice should give same answer
  for format in $formats; do
    $frobby transform -swap01 -oformat $format < $inputFile \
      > /tmp/frobbyTestInvert 2>/dev/null $null;
    $testhelper transform /tmp/frobbyTestInvert $testName.$format \
      -iformat $format -swap01;
    if [ $? != 0 ]; then exit 1; fi
  done

  # Test same-format transform.
  for format in $formats; do
    $testhelper transform $testName.$format $testName.$format $*;
    if [ $? != 0 ]; then exit 1; fi
  done

  # And again with specified formats.
  for format in $formats null; do
    $testhelper transform $testName.$format $testName.$format \
      $* -iformat $format -oformat $format;
    if [ $? != 0 ]; then exit 1; fi
  done

  # Test same-format transform on canon
  $testhelper transform $testName.canon $testName.canon $* $null;
  if [ $? != 0 ]; then exit 1; fi

  # And again with -canon option
  $testhelper transform $testName.canon $testName.canon $* -canon $null;
  if [ $? != 0 ]; then exit 1; fi

  # The Alexander dual option is the only one that reads a raw term
  # that is not a part of an ideal. The -lcm option of analyze is the
  # only one that writes a raw term that is not part of an ideal. We
  # test both of these by adding the lcm at the bottom of an Alexander
  # dual instance. This should not change the output since the
  # Alexander dual assumes the lcm if no point is specified, so we
  # also have a way to ensure that the reading and writing of the term
  # has been done correctly.

  # We first take the intersection of the ideals in the input to
  # ensure that there is only one, since the Alexander dual expects
  # only one.

  for format in $formats; do
    id="-$testName-$format";
    $frobby intersect < $inputFile > /tmp/frobby_intersect$id \
       -oformat $format 2>/dev/null $null;
    $frobby alexdual < /tmp/frobby_intersect$id \
      > /tmp/frobby_alex_out$id 2>/dev/null -canon;
    $frobby transform < /tmp/frobby_intersect$id -minimize 2>/dev/null| \
	  $frobby analyze -summaryLevel 0 -lcm 2>/dev/null| \
      cat /tmp/frobby_intersect$id - > /tmp/frobby_alex_in$id;
    $testhelper alexdual /tmp/frobby_alex_in$id \
      /tmp/frobby_alex_out$id -canon;
    if [ $? != 0 ]; then exit 1; fi
	rm /tmp/frobby_intersect$id /tmp/frobby_alex_in$id /tmp/frobby_alex_out$id
  done
fi

for format in $formats null count; do
  # Test format conversion to $format
  outputFile="$testName.$format";
  $testhelper transform $inputFile $outputFile $* -oformat $format $null;
  if [ $? != 0 ]; then exit 1; fi
done

# Test null input format on this input, which should default to null
# output format and so produce no output.
$testhelper transform $inputFile null.null $* -iformat null

# Test canonicalization of input
outputFile="$testName.canon";
$testhelper transform $inputFile $outputFile $* -canon $null