1* test "sens dc" 2 3v1 1 0 dc=42 4r1 1 2 1k 5r2 2 3 1.5k 6r3 3 0 2.2k 7r4 3 4 3.3k 8r5 4 0 1.8k 9rx 2 4 2.7k 10 11.control 12 13* express our "golden" expectations: 14setplot new 15set gold = $curplot 16 17let v1 = 0.2933065931311105 18let r1 = - 0.004104514242490192 19let r2 = - 2.954317312283796E-4 20let r3 = 0.001129248920024266 21let r4 = - 2.00582596465584E-4 22let r5 = 0.003755608696037442 23let rx = - 0.001494392173796886 24 25* run a "sens" analysis 26sens v(4) dc 27 28strcmp __flag $curplot $gold 29if $__flag = 0 30 echo "ERROR: sens failed to execute" 31 quit 1 32end 33 34* compare results with "golden" expectation 35 36define mismatch(a,b,err) abs(a-b)>err*abs(b) 37 38let total_count = 0 39let fail_count = 0 40 41foreach n v1 r1 r2 r3 r4 r5 rx 42 set n_test = "$n" 43 set n_gold = "{$gold}.$n" 44 if mismatch($n_test, $n_gold, 1e-3) 45 let s_test = $n_test 46 let s_gold = $n_gold 47 echo "ERROR, test failure, s[$n] = $&s_test but should be $&s_gold" 48 let fail_count = fail_count + 1 49 end 50 let total_count = total_count + 1 51end 52 53if fail_count > 0 54 echo "ERROR: $&fail_count of $&total_count tests failed" 55 quit 1 56else 57 echo "INFO: $&fail_count of $&total_count tests failed" 58 quit 0 59end 60 61.endc 62 63.end 64