#!/bin/sh
#
# Test results last captured at "Wed Mar  9 19:48:09 PST 2005"
#
# This is an IBIS icm test program
#
# It is a self-contained package of all of the 
# files and data required to run an icm parser test.
#
# Usage:  ./test_002  <arg>
#
# <nothing>               = Run the test silently in GNU check mode
# "Brief"                 = Run the test.
#                           If there is no error, produce a one line summary
#                           Otherwise, produce a full test report.
# "Full"                  = Run the test and always produce a full test report
# "Capture"               = Capture test results and REWRITE the test program
# "Extract"               = Extract the .icm and .out files
#

Test=`basename $0`
Synopsis="A poorly formatted but correct file"
ExitStatus="0"
Counters="ERRORS: 0 WARNINGS: 1"
ExtraFiles="test_model_1.jpg test_model_2.jpg"

Description=`grep -v '^EOF$' <<'EOF'
This test is of a correct but very badly formatted file.  It is quite
difficult to read, and is intended to expose unexpected conditions
as the parser's internal checks become more rigorous over time.

This test expressly checks a number of parser features including:

1) leading text ignored
2) trailing text ignored
3) whole line and trailing comments everywhere
4) mixed case keywords understood
5) [commend char] directives is a variety of locations
5) keywords ignored before [begin header] and after [end]
6) tab characters everywhere
7) comments embedded in tabular data
8) blank lines embedded in tabular data
9) A pinmap and a nodemap can have the same names (namespaces are separate)
EOF`

Output=`grep -v '^EOF$' <<'EOF'
IBIS ICM Parser, version 1.1.0
WARNING (Line 15/Col 47) One or more TAB characters were found. The use of TABs is discouraged.
Finished. ERRORS: 0 WARNINGS: 1
EOF`

ICM=`grep -v '^EOF$' <<'EOF'

All text before the [Begin Header] keyword <-- that's a test too :) is
to be fair game.  Basically, anything goes in this section.

--->  THIS IS A CORRECT FILE.  It just looks like crap.


The above content is totally disregarded.

[Begin Header]

[ICM Ver] 1.0
| This is a whole line comment
     | As is this.
| There is a <tab> in this comment.  Here: -->	<-- on line 15.

[File Name]           test_002.icm

[Comment Char] |_char                   | This is a trailing comment
[File_Rev]  Revision One Dot Oh  |(NOTE underscore in keyword)        
[Date] January 15, 2003
[Source] Whoever generated this cruft.  Must be me.

 [Source]  <-- this is a test.  It's part of the [Source] text block
as there is a leading space

Keywords lose their significance away from column 1 --> [Source]


[NoTeS] INTERIM FILE  |(NOTE mixed case in keyword)
This is a CORRECT  interim test file.  
There should be no errors, and only two warnings about <tab> characters.

It correctly uses all keywords and features exhibited by the the IBIS ICM 1.0 
Header, save that the redistribution type 'Yes'.  It's not possible to try
more than one in a correct file.  Other files will be needed to test 
remaining redistribution types.

This file will need to be expanded as the prototype implements more of 
the specification.

NOTE ALSO There is a <tab> character here -->	<--

Tab test follows.  Tab stops are modulo 8 as you would normally expect

t2345678t0123456t8901234t6789012t4567890t2345678t0123456t8901234t67890
	one tab
		two tabs
			three tabs
stuff		one tab
t2345678t0123456t8901234t6789012t4567890t2345678t0123456t8901234t67890
<-	<--	<---	<----	<-----	<------	<-	<--	<---


[Comment Char]     %_char               % This is another trailing comment
% Here is another comment

[Disclaimer]

Consult your lawyer if you have trouble understanding the following phrases:

"NOT RESPONSIBLE FOR ANY DAMAGES OF ANY KIND WHATSOEVER".
"USE AT YOUR OWN RISK".

If your computer explodes, it's not my problem.
Your mileage may vary.  
Some restriction apply.  
Read the fine print carefully.


[Copyright] (C) The IBIS Consortium, 2003

[Support] http://nowhere.nohow.com/not/a/chance.html
The spec does not limit keyword in any way.  It's just a pile of text.
Oh, by the way, a comment follows this point --> % here it is!

[Redistribution] Yes
[Redistribution Text] Unrestricted Residistribution of this file is permitted.

vvvvvvvv    expect three blank lines    vvvvvvvvv
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% this is a comment.  It will be removed from the text block %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
^^^^^^^^    expect three blank lines    ^^^^^^^^

This file is licensed under the general terms of the BSD Open source licence.
See the file LICENSE.TXT for details%sss  <-- completely surrounded comment!!

[End Header]

%

[Comment Char] |_char

| Stay tuned, more to come        trailing comment char at end of line --> |
| for all those happy box drawers  :}
|
| lots of comment tests follow

[COMMENT CHAR] !_char
[comment char] "_char
[COMMENT_CHAR] #_char
[CoMmEnT ChaR] $_char
[COMMENT CHAR] %_char
[cOmMeNt_cHaR] &_char
[COMMENT CHAR] '_char
[COMMENT CHAR] (_char

(this is a comment)
(I would test an incorrect x_char, but this is a correct file)

[COMMENT CHAR] (_char
[COMMENT CHAR] )_char
[COMMENT CHAR] *_char
[COMMENT CHAR] ,_char
[COMMENT CHAR] :_char
[COMMENT CHAR] ;_char
[COMMENT CHAR] <_char
[COMMENT CHAR] >_char
[COMMENT CHAR] ?_char
[COMMENT CHAR] @_char
[COMMENT CHAR] \\_char \\ test artifact - need to shell escape this char
[COMMENT CHAR] ^_char
[COMMENT CHAR] \`_char  \` test artifact - need to shell escape this char
[COMMENT CHAR] {_char
[COMMENT CHAR] |_char
[COMMENT CHAR] }_char
[COMMENT CHAR] ~_char

[COMMENT CHAR] |_char

|
| the header above is already checked for self consistency
| using the rules of the 1.0 specification.
|
| The portion below is NOT consistency checked at all.
| ONLY the syntax and grammar is being processed at this time
| Even that's good enough for the parser to catch many, many errors.
| Even without much attention to error messages, the default messages
| state pretty clearly what it found and what it wanted next.
|

[Begin ICM Family]         family name goes here    | spaces are not ruled out
[Manufacturer]              ACME exploding traps
[ICM Family Description]   A favorite of Wil-E-Coyote
[ICM Model List]
|   NAME         |   MATING           |  SLEW        |  IMAGE
dynamite             Mated               100ns          test_model_1.jpg
Anvil                Unmated_side_A      15ps 
bomb                 Unmated_side_B      15ms           test_model_2.jpg

|
| the order of keywords between begin/end model is irrelvant.
|

[Begin ICM Model]  dynamite
  ICM_model_type  MLM
[ICM Model Description]   Another fine ACME product
[Tree Path Description]
  Model_pinmap  RoadRunnerPinMap
  Section       Mult =2    fooby
  Section       Mult = 3  barfy
  Section       Len= 5.7p    yukko
  Fork
    Section     Len=1.0e+2     snert
  Endfork
  Section       Len= 5.7p    yukko
  Model_pinmap  CoyotePinMap

[End ICM Model]


[Begin ICM Model]  Anvil
  ICM_model_type MLM

[ICM Model Description]   Another fine ACME product

[Nodal Path Description]
  Model_nodemap  RoadRunnerPinMap
  N_section ( M0 M1 M2 M3 M4 M5 M6 M7
              C0 C1 C2 C3 C4 C5 C6 C7 )  Mult=1 fooby
  N_section ( C0 C1 C2 C3 C4 C5 C6 C7
              N0 N1 N2 N3 N4 N5 N6 N7 )  Len=3.1415ufoo yukko
  Model_nodemap  CoyotePinMap
[End ICM Model]


[Begin ICM Model]  bomb
  ICM_model_type  MLM

[ICM Model Description]   Another fine ACME product

[Tree Path Description]
  Model_pinmap  RoadRunnerPinMap
  Section       Mult =2    fooby
  Fork
    Section     Len=27.5e-3     snert
  Endfork


  Section       Mult = 3  barfy

  Section       Len= 5.1    yukko
  Fork
    Section     Len=1.     snert
  Endfork

  Section       Mult = 3  barfy
  Model_pinmap  CoyotePinMap

[ICM Swath Parameters]
  Left_edge  =  1
  Right_edge =  1
  Top_edge   =  1
  Bottom_edge = 1

[ICM Swath Pin Numbers]
| NAME       | ROW      | COLUMN
   A            1           1
   B            2           1


   C            3           1
   D            1           2
   E            2           2
   F            3           2

[End ICM Model]

|
| the order of pin/node mapes does not matter
|

[ICM Pin Map] RoadRunnerPinMap
  Pin_order  Column_ordered
  Num_of_rows  =  2
  Num_of_columns = 4
  Pin_list
|  NAME  SIGNAL

   A1   ASD
   A2   QWERT
   A3   LKJH
   A4   MJU

   A5   THM
   A6   EJC
   A7   bleh

   A8   stuff

[ICM Node Map]  RoadRunnerPinMap
|  PIN    NODE    NAME

   0      M0      SIG
   1      M1      SIG

   2      M2      SIG

   3      M3      SIG

   4      M4      SIG
   5      M5      SIG
   6      M6      SIG
   7      M7      SIG

[ICM Node Map]  CoyotePinMap
|  PIN    NODE    NAME

   0      N0      SIG
   1      N1      SIG

   2      N2      SIG

   3      N3      SIG

   4      N4      SIG
   5      N5      SIG  | comment
   6      N6      SIG
   7      N7      SIG


[ICM Pin Map] CoyotePinMap
  Pin_order  Column_ordered
  Num_of_rows  =  2
  Num_of_columns = 4
  Pin_list
|  NAME  SIGNAL

   A1   ASD
   A2   QWERT
   A3   LKJH
   A4   MJU

   A5   THM
   A6   EJC
   A7   bleh

   A8   stuff

[End ICM Family]

|------------------------------------------------------------------------------
|

[Begin ICM Section]       fooby
|
|The resistance matrix for this package does not have coupling
|and is exactly the same as the Diagonal_matrix shown above
|and is described using a trivial version of the Banded_matrix
|as an example only.  The Diagonal_matrix should be used for
|this example to conserve file size.
|
[Derivation Method] Lumped
[Resistance Matrix] Banded_matrix
[Bandwidth] 0
[Row]   1
10.0
[Row]   2
15.0
[Row]   3
15.0
[Row]   4  | comment
10.0            |comment
[Row]   5
10.0
[Row]   6
15.0
[Row]   7
15.0
[Row]   8
10.0
|
|The inductance matrix has coupling between pins:
|
[Inductance Matrix] Full_matrix
[Row]   1
3.04859e-07      0.0             0.0             0.0
0.0              0.0             0.0             0.0
[Row]   2
3.04859e-07      0.0             0.0             0.0
0.0              0.0             0.0             
[Row]   3
3.04859e-07      0.0             0.0             0.0
0.0              0.0   | comment
[Row]   4
3.04859e-07      0.0             0.0             0.0| comment
0.0
[Row]   5
3.04859e-07      0.0             0.0             0.0
[Row]   6
3.04859e-07      0.0             0.0
[Row]   7
3.04859e-07      0.0
[Row]   8
3.04859e-07
|
|The capacitance matrix has sparse coupling:
|
[Capacitance Matrix] Sparse_matrix
[Row]   1
1       2.48227e-10
[Row]   2
2       2.51798e-10
[Row]   3
3       2.51798e-10
[Row]   4
4       2.48227e-10
[Row]   5
5       1.73542e-10
[Row]   6
6       1.86833e-10
[Row]   7
7       1.86833e-10
[Row]   8
8       1.73542e-10

[End ICM Section] fooby

[Begin ICM Section]       yukko
|
|The resistance matrix for this package does not have coupling
|and is exactly the same as the Diagonal_matrix shown above
|and is described using a trivial version of the Banded_matrix
|as an example only.  The Diagonal_matrix should be used for
|this example to conserve file size.
|
[Derivation Method] Distributed
[Resistance Matrix] Banded_matrix
[Bandwidth] 0
[Row]   1
10.0
[Row]   2
15.0
[Row]   3
15.0
[Row]   4  | comment
10.0            |comment
[Row]   5
10.0
[Row]   6
15.0
[Row]   7
15.0
[Row]   8
10.0
|
|The inductance matrix has coupling between pins:
|
[Inductance Matrix] Full_matrix
[Row]   1
3.04859e-07      0.0             0.0             0.0
0.0              0.0             0.0             0.0
[Row]   2
3.04859e-07      0.0             0.0             0.0
0.0              0.0             0.0
[Row]   3
3.04859e-07      0.0             0.0             0.0
0.0              0.0
[Row]   4
3.04859e-07      0.0             0.0             0.0 |comment
0.0
[Row]   5
3.04859e-07      0.0             0.0             0.0
[Row]   6
3.04859e-07      0.0             0.0
[Row]   7
3.04859e-07      0.0
[Row]   8
3.04859e-07
|
|The capacitance matrix has sparse coupling:
|
[Capacitance Matrix] Sparse_matrix
[Row]   1
1       2.48227e-10
[Row]   2
2       2.51798e-10
[Row]   3
3       2.51798e-10
[Row]   4
4       2.48227e-10
[Row]   5
5       1.73542e-10
[Row]   6
6       1.86833e-10
[Row]   7
7       1.86833e-10
[Row]   8
8       1.73542e-10

[End ICM Section] yukko


[Begin ICM Section]       barfy
|
|The resistance matrix for this package does not have coupling
|and is exactly the same as the Diagonal_matrix shown above
|and is described using a trivial version of the Banded_matrix
|as an example only.  The Diagonal_matrix should be used for
|this example to conserve file size.
|
[Derivation Method] Lumped
[Resistance Matrix] Banded_matrix
[Bandwidth] 0
[Row]   1
10.0
[Row]   2
15.0
[Row]   3
15.0
[Row]   4  | comment
10.0            |comment
[Row]   5
10.0
[Row]   6
15.0
[Row]   7
15.0
[Row]   8
10.0
|
|The inductance matrix has coupling between pins:
|
[Inductance Matrix] Full_matrix
[Row]   1
3.04859e-07      0.0             0.0             0.0
0.0              0.0             0.0             0.0
[Row]   2
3.04859e-07      0.0             0.0             0.0
0.0              0.0             0.0
[Row]   3
3.04859e-07      0.0             0.0             0.0
0.0              0.0   | comment
[Row]   4
3.04859e-07      0.0             0.0             0.0  | comment
0.0
[Row]   5
3.04859e-07      0.0             0.0             0.0
[Row]   6
3.04859e-07      0.0             0.0
[Row]   7
3.04859e-07      0.0             
[Row]   8
3.04859e-07      
|
|The capacitance matrix has sparse coupling:
|
[Capacitance Matrix] Sparse_matrix
[Row]   1
1       2.48227e-10
[Row]   2
2       2.51798e-10
[Row]   3
3       2.51798e-10
[Row]   4
4       2.48227e-10
[Row]   5
5       1.73542e-10
[Row]   6
6       1.86833e-10
[Row]   7
7       1.86833e-10
[Row]   8
8       1.73542e-10

[End ICM Section] barfy

[Begin ICM Section] snert
|
|The resistance matrix for this package does not have coupling
|and is exactly the same as the Diagonal_matrix shown above
|and is described using a trivial version of the Banded_matrix
|as an example only.  The Diagonal_matrix should be used for
|this example to conserve file size.
|
[Derivation Method] Distributed
[Resistance Matrix] Banded_matrix
[Bandwidth] 0
[Row]   1
10.0
[Row]   2
15.0
[Row]   3
15.0
[Row]   4  | comment
10.0            |comment
[Row]   5
10.0

[Row]   6
15.0
[Row]   7
15.0
[Row]   8
10.0
|
|The inductance matrix has coupling between pins:
|
[Inductance Matrix] Full_matrix
[Row]   1
3.04859e-07      0.0             0.0             0.0
0.0              0.0             0.0             0.0
[Row]   2
3.04859e-07      0.0             0.0             0.0
0.0              0.0             0.0
[Row]   3
3.04859e-07      0.0             0.0             0.0
0.0              0.0   | comment
[Row]   4
3.04859e-07      0.0             0.0             0.0  | comment
0.0
[Row]   5
3.04859e-07      0.0             0.0             0.0
[Row]   6
3.04859e-07      0.0             0.0
[Row]   7
3.04859e-07      0.0             
[Row]   8
3.04859e-07      
|
|The capacitance matrix has sparse coupling:
|
[Capacitance Matrix] Sparse_matrix
[Row]   1
1       2.48227e-10
[Row]   2
2       2.51798e-10
[Row]   3
3       2.51798e-10
[Row]   4
4       2.48227e-10
[Row]   5
5       1.73542e-10
[Row]   6
6       1.86833e-10
[Row]   7
7       1.86833e-10
[Row]   8
8       1.73542e-10

[End ICM Section] snert


[End]

After the [End] keyword, all residual text is also ignored.  So I've put
some cruft here to make sure that it is.
[End] <-- this should not be recognized as anything special.
[Begin Header]  <-- nor should this be recognized.  One per file.

END OF FILE is here ----->
EOF`

#
# we are either running the test directly in the test directory
# or are running make check.  make sets the srcdir variable
# so we can tell the difference easily
#

if [ -z "${srcdir}" ]
then
    srcdir="."
    exedir="../../src"
else
    srcdir="${srcdir}/v_1_0"
    exedir="../src"
fi

export srcdir exedir Test Synopsis ExitStatus Counters ExtraFiles Description Output ICM

exec ${srcdir}/run_test "$@"
