summaryrefslogtreecommitdiff
path: root/rtems-coverage/generate_coverage_html
blob: 1df2fba13f16149394bdd9e272de93b1c628ecca (plain)
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
#! /bin/sh
#
#  Combine the various reports into a single html file
#

vfile=`dirname $0`/VERSIONS-COVERAGE
if [ ! -r ${vfile} ] ; then
  echo VERSIONS-COVERAGE file not found
  exit 1
fi

source ${vfile}

if [ ! -d ${BASEDIR} ] ; then
  echo Have you set the BASEDIR in VERSIONS correctly?
  exit 1
fi

progname=${0##*/}        # fast basename hack for ksh, bash

USAGE=\
"usage: $progname [ -opts ]
        -v         -- verbose (default=no)
        -p         -- generate plots (default=yes)
        -r VERSION -- RTEMS Version (default=CVS)
"

#   log an error to stderr
prerr()
{
    echo "$*" >&2
}

fatal() {
    prerr "$USAGE"
    [ "$1" ] && (prerr ; prerr $*);
    exit 1
}

toggle()
{
  case $1 in
    no)  echo "yes" ;;
    yes) echo "no" ;;
    *)   fatal "Unknown value to toggle ($1)" ;;
  esac
}

do_plots="yes"
verbose="no"
RTEMS_VERSION="CVS Head"

while getopts vpr: OPT
do
    case "$OPT" in
        r) RTEMS_VERSION="${OPTARG}";;
        p) do_plots=no ;;
        v) verbose=`toggle ${verbose}` ;;
        *) fatal;;
    esac
done

shiftcount=`expr $OPTIND - 1`
shift $shiftcount

if [ $# -ne 1 ] ; then
  fatal Usage: $0 directory
fi

if [ ! -d ${1} ] ; then
  fatal ${1} is not a directory
fi


print_index()
{
cat <<EOF
<HTML>
<HEAD>
<TITLE>RTEMS
EOF

echo ${RTEMS_VERSION}

cat <<EOF
Coverage Reports</TITLE>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<link rel="stylesheet" type="text/css" href="rtems/style.css" media="screen" />
<div class="heading">
<div class="heading-title">RTEMS
EOF

echo ${RTEMS_VERSION}" Coverage Results</div>"
echo "<div class=\"datetime\">"`date`"</div>"

cat << EOF
</div>
</HEAD>
<body>
<br>
<p class="body">For more information on coverage analysis in general visit
<a href="http://www.rtems.org/wiki/index.php/Coverage_Analysis_Theory">
Coverage Analysis Theory</a>.</p>
<p class="body">For information on how the RTEMS Project
views coverage analysis, visit
<a href="http://www.rtems.org/wiki/index.php/RTEMS_Coverage_Analysis">
RTEMS Coverage Testing</a>.</p>
<strong>BSPs with Coverage Results</strong>
<ul>
EOF
for bsp in $BSPs
do
  cpu=`grep "^Target" ${bsp}/${bsp}-*/configuration.txt | \
	sed -e 's/^.*Target: *//' | cut -d'-' -f1 | sort -u`
  echo "<li><a href=\"${bsp}/${bsp}.html\">${cpu}/${bsp}</li>"
done
cat <<EOF
</ul>
EOF
}

print_doc_top()
{
cat <<EOF
<HTML>
<HEAD>
<TITLE>RTEMS
EOF

echo "${RTEMS_VERSION} Coverage Reports for ${1} </TITLE>"
cat <<EOF
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<link rel="stylesheet" type="text/css" href="rtems/style.css" media="screen" />
<script src="rtems/table.js"></script>
<div class="heading">
<div class="heading-title">RTEMS
EOF

echo ${RTEMS_VERSION}" Coverage Results for ${1}</div>"
echo "<div class=\"datetime\">"`date`"</div>"

cat << EOF
</div>
</HEAD>
<body>
<br>
<table class="stats-table" cellspacing="1" cellpadding="2">
EOF
}

print_doc_bottom()
{
cat <<EOF
</body>
EOF
}

print_heading()
{
  if [ "${*}" = "Day" ] ; then
    echo "<th class=\"table-sortable:date\">${*}</th>"
  elif [ "${*}" = "Results" ] ; then
    echo "<th>${*}</th>"
  else
    echo "<th class=\"table-sortable:numeric\">${*}</th>"
  fi
}

# need to use ${1} for parameter
# need to pass
convert_flags() {
  opt=`echo "-${1}" | cut -c1-3`
  pos=`echo "${1}" | cut -c3`
  dev=`echo "${1}" | cut -c4`

  posix="POSIX Enabled"
  deve="Developmental"

  if [ X"${pos}" = X"p" ] ; then
    posix="POSIX Disabled"
  fi

  if [ X"${dev}" = X"d" ] ; then
    deve="Core Only"
  fi

  echo "${opt}, ${posix}, ${deve}"
}

do_perBSPPage()
{
  BSP=${1}
  cpu=`grep "^Target" ${bsp}-*/configuration.txt | \
        sed -e 's/^.*Target: *//' | cut -d'-' -f1 | sort -u`

  print_doc_top ${cpu}/${BSP}

  cat <<EOF
<table align="center">
<thead>
<tr class="heading-title">
EOF
  if [ ${do_plots} = "yes" ] ; then
    echo "<td width=\"30%\">Result Tables</td>"
    echo "<td width=\"30%\">Time Series Graphs</td>"
    echo "<td width=\"30%\">TimePlot Graphs</td>"
  else
    echo "<td>Result Tables</td>"
  fi

cat <<EOF
</thead>
</tr>
<td align="left">
<ul>
<li><a href="#O2pd">-O2, POSIX Disabled, Core Only</a></li>
<li><a href="#O2pD">-O2, POSIX Disabled, Developmental</a></li>
<li><a href="#O2Pd">-O2, POSIX Enabled, Core Only</a></li>
<li><a href="#O2PD">-O2, POSIX Enabled, Developmental</a></li>
<li><a href="#Ospd">-Os, POSIX Disabled, Core Only</a></li>
<li><a href="#OspD">-Os, POSIX Disabled, Developmental</a></li>
<li><a href="#OsPd">-Os, POSIX Enabled, Core Only</a></li>
<li><a href="#OsPD">-Os, POSIX Enabled, Developmental</a></li>
</ul>
</td>
<td>
<ul>
EOF


  if [ ${do_plots} = "yes" ] ; then
    echo "<li><a href=\"graphs/${BSP}-uncovered_percent-d.png\">"
    echo "  Uncovered Percentage (Core)</a></li>"
    echo "<li><a href=\"graphs/${BSP}-uncovered_percent-D.png\">"
    echo "  Uncovered Percentage (Developmental)</a></li>"

    echo "<li><a href=\"graphs/${BSP}-total_bytes-d.png\">"
    echo "  Total Bytes Analyzed (Core)</a></li>"
    echo "<li><a href=\"graphs/${BSP}-total_bytes-D.png\">"
    echo "  Total Bytes Analyzed (Developmental)</a></li>"

    echo "<li><a href=\"graphs/${BSP}-ranges-d.png\">"
    echo "  Uncovered Ranges (Core)</a></li>"
    echo "<li><a href=\"graphs/${BSP}-ranges-D.png\">"
    echo "  Uncovered Ranges (Developmental)</a></li>"

    echo "<li><a href=\"graphs/${BSP}-uncovered_bytes-d.png\">"
    echo "  Uncovered Bytes (Core)</a></li>"
    echo "<li><a href=\"graphs/${BSP}-uncovered_bytes-D.png\">"
    echo "  Uncovered Bytes (Developmental)</a></li>"
  fi

cat <<EOF
</ul>
</td>
<td>
<ul>
EOF

  if [ ${do_plots} = "yes" ] ; then
    echo "<li><a href=\"graphs/timeplot-${BSP}.html\">"
    echo "  TimePlot Graphs</a></li>"

    echo "<li><a href=\"graphs/timeplot-${BSP}.html#uncovered_percent\">"
    echo "  Uncovered Percentage</a></li>"

    echo "<li><a href=\"graphs/timeplot-${BSP}.html#total_bytes\">"
    echo "  Total Bytes Analyzed</a></li>"

    echo "<li><a href=\"graphs/timeplot-${BSP}.html#ranges\">"
    echo "  Uncovered Ranges</a></li>"

    echo "<li><a href=\"graphs/timeplot-${BSP}.html#uncovered_bytes\">"
    echo "  Uncovered Bytes</a></li>"
  fi

cat <<EOF
</ul>
</td>
</tr>
</table>
</br>
EOF

  #cat ${bsp}-*-*-*/row.html | sed -e 's/<TD>/<TD><CENTER>/g' \
  #   -e 's/<\/TD>/<\/CENTER><\/TD>/g'

  # 1   2      3      4
  #bsp-opt-yyyymmdd-hhmm.tar.bz2
  # sort 1,2 alphabetically, sort 3,4 reverse "version"
  first="yes"
  for build in O2pd O2pD O2Pd O2PD Ospd OspD OsPd OsPD
  do
    echo "<a name=\"${build}\"></a>"
    echo "<table class=\"stats-table table-autosort\" cellspacing=\"1\" cellpadding=\"2\">"
    echo "<thead>"
    echo "<tr class=\"stats-table-target\">"
    echo "<td colspan=\"10\">"
    echo "<strong>${cpu}/${bsp} `convert_flags ${build}` (${build})</strong>"
    echo "</td>"
    echo "</tr>"
    echo "<tr class=\"stats-table-top\">"
    ### generate header
    print_heading Day
    print_heading Time
    print_heading Version
    print_heading Uncovered Ranges
    # skip Uncovered Percentage
    print_heading Covered Percentage
    print_heading Uncovered Bytes
    print_heading Total Bytes
    print_heading Results
    echo "</thead>"

    first=no
    ls -1 ${bsp}-${build}-*-*/row.html | sort -t -  -k 1,2 -k 3,4r | \
    while read row
    do
     index=`echo ${row} | sed -e 's/row/index/'`
     sed \
      -e '1,1s/<TR>/<tr class="stats-table-row">/'  \
      -e '2,2s/<TD>\(20[0-9][0-9]\)\([0-1][0-9]\)\([0-3][0-9]\)/<TD>\1-\2-\3/' \
      -e '4,13d' \
     <$row
     version="unknown"
     if [ -r ${index} ] ; then
       version=`grep heading-title ${index} | \
          sed -e 's/<.*>RTEMS //' -e 's/<.*$//'`
     fi

     echo "<TD>${version}</TD>"
     sed \
      -e '1,6d' \
      -e '7,7s/<TD>0/<td class="stats-target-good">0/' \
      -e '8d' \
      -e '9,9s/<TD>100/<td class="stats-target-good">100/' \
      -e '10,10s/<TD>0/<td class="stats-target-good">0/' \
      <$row
    done | \
     sed -e 's/<[tT][dD]/<td align="center"/'
    echo "</table>"
    echo "</br>"
  done
  print_doc_bottom
}

genBSPList()
{
  find * -type d -name "*-O[s2][pP][dD]-2???[012]???-????" | \
    cut -d'-' -f1 | uniq | \
    while read dir
    do
      bsp=`basename ${dir} | sed -e 's/.*\/.*-//'`
      cpu=`grep ^Target ${dir}-*/configuration.txt | tail -1 | \
        sed -e 's/^.*Target//' | cut -d':' -f2 | cut -d'-' -f1`
      echo ${cpu}/${bsp}
    done | sort -u | sort -t / -k 1 -k 2 | cut -d'/' -f2
    # sort cpu,bsp alphabetically
}

cleanup()
{
  for bsp in ${BSPs}
  do
    count=`ls -1 ${bsp}*.tar.bz2 | wc -l`
    if [ ${count} -gt 20 ] ; then
      echo ${bsp} has ${count} entries.. cleaning it
      ls -1 ${bsp}-*.tar.bz2 |  sort -t - -k 3 -k 2 -r | sed -e '1,20d' | \
      while read f
      do
        dir=`echo ${f} | sed -e 's/.tar.bz2$//'`
        rm -rf ${f} ${dir}
      done
    fi

  done
}

# round up
round_up()
{
  num=$1
  round=$2
  echo ${num} ${num} ${round} + ${round} % - ${round} + p | dc
}

# round down
round_down()
{
  num=$1
  round=$2
  echo ${num} ${num} ${round} - ${round} % - ${round} - p| dc
}

# Generate the GNU Plot script
gen_plot()
{
  # Now merge the data
  datfiles=`ls -1 ${OUTDAT}/${bsp}-*${DEV}-${FIELD}.dat`
  first=`cat ${datfiles} | sort -t' ' -k1.3 -n | head -n 1 | cut -d' ' -f1`
  last=`cat ${datfiles} | sort -t' ' -k1.3 -n | tail -n 1 | cut -d' ' -f1`

  min=`cat ${datfiles} | sort -k2 -n | head -n 1 | cut -d' ' -f2`
  max=`cat ${datfiles} | sort -k2 -n | tail -n 1 | cut -d' ' -f2`
  round=
  case ${FIELD} in
    ranges)
      round=10
      min=`round_down ${min} 10 0`
      max=`round_up   ${max} 10 1000000`
      YLABEL=Ranges
      ;;
    covered_percent)
      max=100.0
      YLABEL=Covered
      ;;
    uncovered_percent)
      min=0
      YLABEL=Uncovered
      ;;
    uncovered_bytes)
      round=1000
      min=`round_down ${min} 1000 0`
      max=`round_up   ${max} 1000 1000000`
      YLABEL=Uncovered
      ;;
    total_bytes)
      round=5000
      min=`round_down ${min} 5000 0`
      max=`round_up   ${max} 5000 1000000`
      YLABEL=Total
      ;;
    *)
      echo "ERROR unknown FIELD ${FIELD}"
      exit 1
      ;;
  esac
  # No negative numbers. :=D
  if [ ${min} -lt 0 ]  ; then
    min=0
  fi
  if [ "X${round}" != "X" ] ; then   # definitely integer
    if [ ${min} -eq ${max} ] ; then
      max=`expr ${min} + ${round}`
    fi
  fi

  # Is this graph using data for developmental or core configurations?
  if [ ${DEV} = "D" ] ; then
    TITLE="${PATTERN} (Developmental)"
  else
    TITLE="${PATTERN} (Core)"
  fi

  Year=`echo ${first} | cut -c1-4`
  Month=`echo ${first} | cut -c6-7`
  Day=`echo ${first} | cut -c9-10`
  Hour=`echo ${first} | cut -c12-13`
  Minute=`echo ${first} | cut -c15-16`
  start="${Year}-${Month}-${Day}/${Hour}:${Minute}"

  Year=`echo ${last} | cut -c1-4`
  Month=`echo ${last} | cut -c6-7`
  Day=`echo ${last} | cut -c9-10`
  Hour=`echo ${last} | cut -c12-13`
  Minute=`echo ${last} | cut -c15-16`
  end="${Year}-${Month}-${Day}/${Hour}:${Minute}"

  echo "set terminal png size 1200,800"
  echo "set xdata time"
  echo "# time range must be in same format as data file"
  echo "# YYYYMMDD-HHMMSS"
  echo "set timefmt \"%Y-%m-%d/%H:%M:%S\""
  echo "set output \"${OUTFIG}/${bsp}-${FIELD}-${DEV}.png\""
  echo "set xrange [\""${start}"\":\""${end}"\"]"
  echo "set yrange [${min}:${max}]"
  echo "set grid"
  echo "set xlabel \"Date\""
  echo "set ylabel \"${YLABEL}\""
  echo "set title \"${TITLE}\""
  echo "set key left box"

  echo "plot \"${OUTDAT}/${bsp}-Osp${DEV}-${FIELD}.dat\" using 1:2 index 0 \\"
  echo "  title \"Osp${DEV}\" with lines lw 2, \\"
  echo "     \"${OUTDAT}/${bsp}-OsP${DEV}-${FIELD}.dat\" using 1:2 index 0 \\"
  echo "  title \"OsP${DEV}\" with lines lw 2, \\"
  echo "     \"${OUTDAT}/${bsp}-O2p${DEV}-${FIELD}.dat\" using 1:2 index 0 \\"
  echo "  title \"O2p${DEV}\" with lines lw 2, \\"
  echo "     \"${OUTDAT}/${bsp}-O2P${DEV}-${FIELD}.dat\" using 1:2 index 0 \\"
  echo "  title \"O2P${DEV}\" with lines lw 2"
}

gen_data()
{
  for s in `ls -1 ${bsp}/${bsp}-${CONF}-*/summary.txt | sort `
  do
    timestamp=`echo $s | cut -d'-' -f3-4 | cut -d'/' -f1`
    case ${FIELD} in
      ranges)
        num=`grep "${PATTERN}" $s | cut -d' ' -f1`
        if [ "X${num}" = "X" ] ; then
          num=`grep -i "${PATTERN}" $s | cut -d':' -f2`
        fi
        ;;
      *)      num=`grep "${PATTERN}" $s | cut -d':' -f2` ;;
    esac

    Year=`echo ${timestamp} | cut -c1-4`
    Month=`echo ${timestamp} | cut -c5-6`
    Day=`echo ${timestamp} | cut -c7-8`
    stamp="${Year}-${Month}-${Day}"

    echo ${stamp} ${num}
  done
}

gen_timeplot()
{
BSP=$1

LEGEND_TABLE_BODY="\
<table>\
<tr>\
  <td style="color:#ff0000">O2pd</td>\
  <td style="color:#D0A825">O2pD</td>\
  <td style="color:#336699">O2Pd</td>\
  <td style="color:#99FF00">O2PD</td>\
  <td style="color:#336666">Ospd</td>\
  <td style="color:#33CC33">OspD</td>\
  <td style="color:#990099">OsPd</td>\
  <td style="color:#ff0099">OsPD</td>\
</tr>\
</table>"

cat <<EOF
<HTML>
<HEAD>
<TITLE>${BSP} Timeplot Graphs</TITLE>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<link rel="stylesheet" type="text/css" href="rtems/style.css" media="screen" />
EOF

cat << EOF

    <script src="http://api.simile-widgets.org/timeplot/1.1/timeplot-api.js"
       type="text/javascript"></script>
    <script type="text/javascript">
      var timeplot = [];
      var types  = ["O2pd", "O2pD", "O2Pd", "O2PD", "Ospd", "OspD", "OsPd", "OsPD"];
      var graphs = ["ranges", "total_bytes", "uncovered_bytes", "uncovered_percent"];
      var lineColors = ["#ff0000", "#D0A825", "#336699", "#99FF00", "#336666", "#33CC33", "#990099", "#FF0099"];
      var eventsources;
      var plotInfo;

      function onLoad() {
	for( i = 0; i<graphs.length; i++)
	{
	    var timeGeometry = new Timeplot.DefaultTimeGeometry({
	        gridColor: new Timeplot.Color("#000000"),
		axisLabelsPlacement: "top"
	    });

	    var valueGeometry = new Timeplot.DefaultValueGeometry({
	        gridColor: "#000000",
	        axisLabelsPlacement: "left"
	    });

	    eventsources = [];
	    plotInfo = [];
	    for( j = 0; j<types.length; j++)
	    {
	      eventsources[j] = new Timeplot.DefaultEventSource();
	      plotInfo[j] = Timeplot.createPlotInfo({
		 id: "plot"+(j+1),
		 dataSource: new Timeplot.ColumnSource(eventsources[j],1),
		 timeGeometry: timeGeometry,
		 valueGeometry: valueGeometry,
		 lineColor: lineColors[j]
	      });
	    }
	    timeplot[i] = Timeplot.create(document.getElementById(graphs[i]+"-timeplot"), plotInfo);
	    for( j = 0; j<types.length; j++)
	    {
	      timeplot[i].loadText("../plot_data/" + "${BSP}-" + types[j] + "-" + graphs[i] + ".dat", " ", eventsources[j]);
	    }
	  }
      }
      var resizeTimerID = null;
      function onResize() {
	if (resizeTimerID == null) {
	resizeTimerID = window.setTimeout(
		    function() {
			resizeTimerID = null;
			for( i = 0; i< timeplot.lenght; i++)
			{
			  timeplot[i].repaint();
			}
		    }, 100);
	  }
      }

    </script>
  </head>
  <body onload="onLoad();" onresize="onResize();">
    <h1>${BSP} Timeplot Graphs</h1>
    <li><a href="#uncovered_percent">Uncovered Percentage Graph</a></li>
    <li><a href="#total_bytes">Total Bytes Analyzed Graph</a></li>
    <li><a href="#ranges">Uncovered Ranges Graph</a></li>
    <li><a href="#uncovered_bytes">Uncovered Bytes Graph</a></li>

    <h2 id="uncovered_percent">Uncovered Percentage</h2>
    ${LEGEND_TABLE_BODY}
    <div id="uncovered_percent-timeplot" style="height: 500px;"></div>

    <h2 id="total_bytes">Total Bytes Analyzed</h2>
    ${LEGEND_TABLE_BODY}
    <div id="total_bytes-timeplot" style="height: 500px;"></div>
    <h2 id="ranges">Uncovered Ranges</h2>

    ${LEGEND_TABLE_BODY}
    <div id="ranges-timeplot" style="height: 500px;"></div>

    <h2 id="uncovered_bytes">Uncovered bytes</h2>
    ${LEGEND_TABLE_BODY}
    <div id="uncovered_bytes-timeplot" style="height: 500px;"></div>
  </body>
</html>
EOF
}

#
# Now start the non-method code
#

cd $1

good_dir="no"
for d in `ls -1 *.tar.bz2 */*.tar.bz2 2>/dev/null | sed -e 's/.tar.bz2$//'`
do
  good_dir="yes"
  if [ ! -d ${d} ] ; then
    tar xjf ${d}.tar.bz2
  fi
done

if [ ${good_dir} = "no" ]; then
  echo "No tarballs.  Is $1 really a coverage publishing directory?"
  exit 1
fi

echo "Generating HTML reports for RTEMS ${RTEMS_VERSION}"

# Put the style sheets in place
if [ ! -d rtems ] ; then
  mkdir rtems
fi

cp ${COVBASE}/style.css rtems/style.css

# Find the BSPs and make their directories
echo "Generating BSP list"
#BSPs=`find * -maxdepth 1 -type d | cut -d'-' -f1 | uniq | grep -v rtems`
BSPs=`genBSPList`
echo BSPs=${BSPs}

echo "Ensuring BSP specific content is in BSP subdirectory"
for bsp in ${BSPs}
do
  test -d ${bsp}           || mkdir ${bsp}
  test -d ${bsp}/rtems     || mkdir ${bsp}/rtems
  test -d ${bsp}/plot_data || mkdir ${bsp}/plot_data
  test -d ${bsp}/graphs    || mkdir ${bsp}/graphs
  cp ${COVBASE}/style.css ${bsp}/rtems/style.css
  cp ${COVBASE}/../covoar/table.js ${bsp}/rtems/table.js
  cp ${COVBASE}/../covoar/filter.gif ${bsp}/rtems
  cp ${COVBASE}/../covoar/05_ascending.gif ${bsp}/rtems
  cp ${COVBASE}/../covoar/05_descending.gif ${bsp}/rtems
  cp ${COVBASE}/../covoar/05_unsorted.gif ${bsp}/rtems
  mv ${bsp}-* ${bsp} 2>/dev/null
done

# Let them grow for a while
# cleanup

echo "Generating master index.html"
print_index >index.html

# now generate a page per BSP with plots and graphs

for bsp in ${BSPs}
do
  echo "Generating BSP Page for ${bsp}..."
  cd $1/${bsp}
  do_perBSPPage ${bsp} >${bsp}.html

  if [ ${do_plots} = "yes" ] ; then
    cd $1
    OUTFIG=${bsp}/graphs
    OUTDAT=${bsp}/plot_data
    echo "Generating Static Plots for ${bsp}..."
    for FIELD in ranges total_bytes uncovered_bytes \
      uncovered_percent #covered_percent
    do
      # Pattern to find in summary.txt
      case ${FIELD} in
        ranges)            PATTERN="Uncovered Ranges Found" ;;
        covered_percent)   PATTERN="Percentage Executed" ;;
        uncovered_percent) PATTERN="Percentage Not Executed" ;;
        total_bytes)       PATTERN="Bytes Analyzed" ;;
        uncovered_bytes)   PATTERN="Bytes Not Executed" ;;
        *)                 echo "Unknown field (${FIELD})"; exit 1 ;;
      esac

      for DEV in d D
      do
        for CONF in Osp${DEV} OsP${DEV} O2p${DEV} O2P${DEV}
        do
          gen_data ${bsp} ${CONF} >${OUTDAT}/${bsp}-${CONF}-${FIELD}.dat
        done

        pltfile=${OUTDAT}/${bsp}-${FIELD}-${DEV}.plt
        gen_plot >${pltfile}
        gnuplot ${pltfile}
      done
    done

    echo "Generating Time Plots for ${bsp}..."
    timeplotfile=${OUTFIG}/timeplot-${bsp}.html
    gen_timeplot ${bsp} > ${timeplotfile}
  fi
done
exit 0