File: pcb-rtrip

package info (click to toggle)
pcb-rnd 3.1.7b-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,108 kB
  • sloc: ansic: 213,400; yacc: 6,241; sh: 4,698; awk: 3,016; makefile: 2,254; lex: 1,166; python: 519; xml: 261; lisp: 154; tcl: 67; perl: 34; javascript: 6; ruby: 5
file content (122 lines) | stat: -rwxr-xr-x 2,727 bytes parent folder | download | duplicates (5)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/sh
#   pcb-rtrip - load-save-load round trip tester
#   Copyright (C) 2016 Tibor 'Igor2' Palinkas
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License along
#   with this program; if not, write to the Free Software Foundation, Inc.,
#   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#   http://repo.hu/projects/pcb-rnd

pcb_rtrip()
{
	rm -f "$fn.new.pcb"

	if test ! -z "$remtgt"
	then
		rm -f "$fn.trgt.$ext"
	fi

echo '
SaveTo(LayoutAs, '$fn'.orig.pcb, pcb)
LoadFrom(Layout, '$fn'.orig.pcb)
SaveTo(LayoutAs, '$fn'.trgt.'$ext', '$fmt')
LoadFrom(Layout, '$fn'.trgt.'$ext', '$fmt')
SaveTo(LayoutAs, '$fn'.new.pcb, pcb)
' | $valg $pcb_rnd_bin --gui batch "$fn"

	if test -f "$fn.orig.pcb" -a -f "$fn.new.pcb"
	then
		diff -u "$fn.orig.pcb" "$fn.new.pcb"
	else
		if test ! -f "$fn.orig.pcb"
		then
			echo "Failed to load $fn"
		else
			echo "Failed to load $fn.trgt.$ext"
		fi
	fi
}

set_ext()
{
	case "$fmt"
	in
		lihata) ext="lht";;
		pcb) ext="pcb";;
		*) ext="$fmt";;
	esac
}

help()
{
	echo "pcb-rtrip - load-save-load round trip tester"
	echo ""
	echo "Load a board, save it (*.orig.pcb), load it, save it in the target"
	echo "format (*.trgt.*), load it again and save it (*.new.pcb). Calculate"
	echo "the diff between *.orig.pcb and *.new.pcb; if load-save-load round trip"
	echo "of a target format is lossles, the diff is empty."
	echo ""
	echo "Invocation: $0 [-f fmt] [input.pcb]"
	echo "Switches:"
	echo " -f fmt   format (e.g. lihata)"
	echo " -r       remove target before overwrite"
	echo " -b bin   run bin instead of \"pcb-rnd\""
	echo " -V       wrap the binary in valgrind"
	echo ""
}


# defaults
fmt="lihata"
fn=""
remtgt=""
if test -z "$pcb_rnd_bin"
then
	pcb_rnd_bin="pcb-rnd"
fi
valg=""

while test $# -gt 0
do
	case "$1"
	in
		--help) help "$0"; exit 0;;
		-f) fmt=$2; shift 1;;
		-b) pcb_rnd_bin=$2; shift 1;;
		-V) valg="valgrind -v";;
		-r) remtgt=1;;
		*)
			if test -z "$fn"
			then
				fn="$1"
			else
				echo "unknown switch $1; try --help" >&2
				exit 1
			fi
			;;
		-*) echo "unknown switch $1; try --help" >&2; exit 1;;
	esac
	shift 1
done

if test -z "$fn"
then
	echo "no fn"
	exit 1
	fn="pcb-rtrip.pcb"
	cat >$fn
fi

set_ext
pcb_rtrip