From joel@mail.acm.org  Thu Dec 14 20:30:42 2000
MIME-Version: 1.0
Sender: joel@mail.acm.org
Date: Wed, 13 Dec 2000 14:56:26 -0600
From: Joel Sherrill <joel.sherrill@OARcorp.com>
Reply-To: joel.sherrill@OARcorp.com
Organization: OAR Corporation
X-Accept-Language: en
To: guerby@acm.org
Subject: acats files (finally)
Content-Type: multipart/mixed;
 boundary="------------C0682C92A969A813F2F40526"
X-Mmail: \Recent                                 
X-M-Uid: 0065932.976741803

This is a multi-part message in MIME format.
--------------C0682C92A969A813F2F40526
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


rtems_init.c, native.cfg and erc32.cfg all reside in the config
directory.  I may have config one level off in the tree but the
concept is OK.

Attached.

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel@OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (256) 722-9985
--------------C0682C92A969A813F2F40526
Content-Type: application/x-sh;
 name="run_all.sh"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="run_all.sh"

#!/bin/bash -x
# $Id$
# Laurent Guerby <guerby@acm.org>
# Run ACATS 2.3 with the GNU Ada compiler

# The following functions are to be customized if you run in cross
# environment or want to change compilation flags.  Note that for
# tests requiring checks not turned on by default, this script
# automatically adds the needed flags to pass (ie: -gnato or -gnatE).

EXTERNAL_OBJECTS=""
# Global variable to communicate external objects to link with, set by the script.

host_gnatmake () {
gnatmake $* -largs $EXTERNAL_OBJECTS
}

host_gcc () {
gcc $*
}

# figure out our base directory
dir=$(dirname $(pwd))

if [ $(basename $(pwd)) != "work" ]; then
   echo You must be in the work directory
   exit 1
else
   echo dir $dir
fi

# now get target compilation files.
target=${1}
# if no target specified, then use native configuration (i.e. host = target)
if test "${target}"X = "X" ; then
  target=native
fi

# Now read the target configuration file
if ! test -r $dir/config/${target}.cfg ; then
  echo No configuration file for ${target}
  exit 1
fi

. ${dir}/config/${target}.cfg

# End of customization section.

echo ==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%== download ==%%== $(date)

if [ ! -d $dir/c2 ]; then
   cd $dir/download
   wget http://www.adaic.org/compilers/acvc/95acvc/acvc2_3/tar/acats231.tar.Z
   wget http://www.adaic.org/compilers/acvc/95acvc/acvc2_3/tar/acats232.tar.Z
   wget http://www.adaic.org/compilers/acvc/95acvc/acvc2_3/tar/acats233.tar.Z
   wget http://www.adaic.org/compilers/acvc/95acvc/acvc2_3/tar/acats234.tar.Z
   wget http://www.adaic.org/compilers/acvc/95acvc/acvc2_3/tar/acats235.tar.Z
   wget http://www.adaic.org/compilers/acvc/95acvc/acvc2_3/tar/acats236.tar.Z
   wget http://www.adaic.org/compilers/acvc/95acvc/acvc2_3/tar/acats237.tar.Z
   wget http://www.adaic.org/compilers/acvc/95acvc/acvc2_3/tar/acats238.tar.Z
   wget http://www.ada-auth.org/~acats/acats-files/mod_2_3e.tar.Z   

   cd $dir
   tar xfz $dir/download/acats231.tar.Z
   tar xfz $dir/download/acats232.tar.Z
   tar xfz $dir/download/acats233.tar.Z
   tar xfz $dir/download/acats234.tar.Z
   tar xfz $dir/download/acats235.tar.Z
   tar xfz $dir/download/acats236.tar.Z
   tar xfz $dir/download/acats237.tar.Z
   tar xfz $dir/download/acats238.tar.Z
   
   cd $dir/mod
   tar xfz $dir/download/mod_2_3e.tar.Z 

fi

if [ ! -d $dir/c2 ]; then
   echo Unsuccessfull download
   exit 1
fi

if [ ! -d $dir/c9.slow ]; then
   cp -r $dir/c9 $dir/c9.slow
   cd $dir/c9
   patch < $dir/acats4gnat/fastc9.patch
fi

echo ==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%== support ==%%== $(date)

/bin/rm -rf $dir/work/support
mkdir -p $dir/work/support
cd $dir/work/support

sed -e "s,ACATS4GNATDIR,$dir,g" < $dir/acats4gnat/impdef.a > $dir/support/impdef.a
sed -e "s,ACATS4GNATDIR,$dir,g" < $dir/acats4gnat/macro.dfs > $dir/work/support/MACRO.DFS
sed -e "s,ACATS4GNATDIR,$dir,g" < $dir/acats4gnat/tsttests.dat > $dir/work/support/TSTTESTS.DAT

cat < $dir/acats4gnat/fcndecl.ada > $dir/support/fcndecl.ada
cat < $dir/acats4gnat/impdefc.a > $dir/support/impdefc.a
cat < $dir/acats4gnat/impdefg.a > $dir/support/impdefg.a

cat < $dir/mod/c392010.a > $dir/c2/c392010.a
cat < $dir/mod/c433001.a > $dir/c4/c433001.a
cat < $dir/mod/c761010.a > $dir/c7/c761010.a
cat < $dir/mod/cb41002.a > $dir/cb/cb41002.a 
cat < $dir/mod/cxb3015.a > $dir/cxb/cxb3015.a

cp $dir/cd/*.c $dir/work/support
cp $dir/cxb/*.c $dir/work/support

for i in $dir/support/{*.ada,*.a}; do 
   echo ===== $i 
   gnatchop $i
done

# These tools are used to preprocess some ACATS sources
# they need to be compiled native on the host.

host_gcc -c cd300051.c
EXTERNAL_OBJECTS="cd300051.o"
host_gnatmake macrosub
if [ $? -ne 0 ]; then
   echo Failed to compile macrosub
   exit 1
fi
EXTERNAL_OBJECTS=""
$dir/work/support/macrosub

host_gnatmake widechr
if [ $? -ne 0 ]; then
   echo Failed to compile widechr
   exit 1
fi
$dir/work/support/widechr

/bin/rm -f $dir/work/support/{macrosub,widechr,*.ali,*.o}

# From here, all compilations will be made by the target compiler

target_setup

target_gcc -c *.c
if [ $? -ne 0 ]; then
   echo Failed to compile C code
   exit 1
fi

gnatchop $dir/support/*.adt

target_gnatmake -c -f -gnato report.adb

for i in *.ad?; do 
   file=$(echo $i | sed -e 's/\(.*\)\..*/\1/g')
   if [ "$i" = "report.adb" ]; then
      echo ===== $i "(done)"
   elif [ "$i" = "${file}.ads" -a -f ${file}.adb ]; then
      echo ===== $i "(spec)"
   else    
      echo ===== $i 
      target_gnatmake -c $i
   fi
done

echo ==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%== tests ==%%== $(date)

/bin/rm -rf $dir/work/run
mkdir -p $dir/work/run

# error only: b* lxd lxe lxh
for chapter in cz a c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cxa cxb cxc cxd cxe cxf cxg cxh d e l; do
   echo ""
   echo ""
   echo ""
   echo ==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%== $chapter ==%%== $(date)
   /bin/rm -rf $dir/work/$chapter
   mkdir -p $dir/work/$chapter
   cd $dir/$chapter
   ls -1 *.{a,ada,adt,am,dep} 2> /dev/null | sed -e 's/\(.*\)\..*/\1/g' | cut -c1-7 | sort | uniq | comm -23 - $dir/acats4gnat/norun.lst > $dir/work/$chapter/${chapter}.lst 
   countn=$(wc -l < $dir/work/$chapter/${chapter}.lst)
   echo "expected = $countn"
   countok=0
   counti=0
   for i in $(cat $dir/work/$chapter/${chapter}.lst); do 
      counti=$((counti + 1))
      echo ""
      echo "" 
      echo =%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%=%= $i =%=%= $(date) =%=%= $counti / $countn
      extraflags=""
      grep $i $dir/acats4gnat/overflow.lst > /dev/null 2>&1
      if [ $? -eq 0 ]; then
         extraflags="$extraflags -gnato"
      fi
      grep $i $dir/acats4gnat/elabd.lst > /dev/null 2>&1
      if [ $? -eq 0 ]; then
         extraflags="$extraflags -gnatE"
      fi
      mkdir $dir/work/$chapter/$i
      cd $dir/work/$chapter/$i
      gnatchop -c -w $(ls $dir/${chapter}/${i}*.{a,ada,adt,am,dep} 2> /dev/null)
      echo > ${i}.lst
      ls -1 ${i}?.adb >> ${i}.lst 2> /dev/null
      ls -1 ${i}*m.adb >> ${i}.lst 2> /dev/null
      ls -1 ${i}.adb >> ${i}.lst 2> /dev/null
      main=$(tail -1 ${i}.lst)
      binmain=$(echo $main | sed -e 's/\(.*\)\..*/\1/g')
      echo "main =" $main "binmain = " $binmain
      EXTERNAL_OBJECTS=""
      case $i in
        cxb30*) EXTERNAL_OBJECTS="$dir/work/support/cxb30040.o $dir/work/support/cxb30060.o $dir/work/support/cxb30130.o $dir/work/support/cxb30131.o";;
        ca1020e) /bin/rm -f ca1020e_func1.adb ca1020e_func2.adb ca1020e_proc1.adb ca1020e_proc2.adb > /dev/null 2>&1;;
        ca14028) /bin/rm -f ca14028_func2.ads ca14028_func3.ads ca14028_proc1.ads ca14028_proc3.ads > /dev/null 2>&1;;
        cxh1001) extraflags="-a -f"; echo "pragma Normalize_Scalars;" > gnat.adc
      esac
      if [ "$main" = "" ]; then
         echo SCRIPT-MAIN FAILED
      else
         target_gnatmake $extraflags -I$dir/work/support $main
      fi
      if [ $? -ne 0 ]; then
         echo SCRIPT-BUILD FAILED $i
      fi
      cd $dir/work/run
      target_run $dir/work/$chapter/$i/$binmain > $dir/work/$chapter/$i/${i}.log 2>&1 </dev/null
      cd $dir/work/$chapter/$i
      cat ${i}.log
      egrep -e '(==== |\+\+\+\+ |\!\!\!\! )' ${i}.log > /dev/null 2>&1
      if [ $? -ne 0 ]; then
         echo SCRIPT-RUN FAILED $i
      else
         countok=$((countok + 1))
      fi
      /bin/rm -f "$binmain" *.o *.ali > /dev/null 2>&1
   done
   echo ""
   echo "acats4gnat results $chapter $countok / $countn"
done

echo ==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%==%%== done ==%%== $(date)

exit 0


--------------C0682C92A969A813F2F40526
Content-Type: text/plain; charset=us-ascii;
 name="rtems_init.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="rtems_init.c"

/* 
 *  COPYRIGHT (c) 1989-1997.
 *  On-Line Applications Research Corporation (OAR).
 *  Copyright assigned to U.S. Government, 1994.
 *
 *  The license and distribution terms for this file may be found in
 *  the file LICENSE in this distribution or at
 *  http://www.OARcorp.com/rtems/license.html.
 *
 *  $Id: init.c,v 1.2 1999/08/20 19:37:42 joel Exp $
 */

#include <bsp.h>

#include <assert.h>
#include <pthread.h>

#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>

extern rtems_configuration_table  BSP_Configuration;

#ifdef GNAT_PID
#include <unistd.h>
pid_t getpid()
{
  return GNAT_PID;
}
#endif

/*
 *  By having the POSIX_Init thread create a second thread just
 *  to invoke gnat_main, we can override all default attributes
 *  of the "Ada environment task".  Otherwise, we would be
 *  stuck with the defaults set by RTEMS.
 */
 
void *start_gnat_main( void * argument )
{
  extern int gnat_main ( int argc, char **argv, char **envp );

  (void) gnat_main ( 0, 0, 0 );

  exit( 0 );

  return 0;
}

void *POSIX_Init( void *argument )
{
  pthread_t       thread_id;
  pthread_attr_t  attr;
  size_t          stacksize = _ada_pthread_minimum_stack_size();
  int             status;

  status = pthread_attr_init( &attr );
  assert( !status );

#define GNAT_MAIN_STACKSPACE 100
#ifdef GNAT_MAIN_STACKSPACE
  stacksize = GNAT_MAIN_STACKSPACE * 1024;
#else
#define GNAT_MAIN_STACKSPACE 0
#endif

  /* for file oriented tests */
  mkdir( "/tmp", 0777 );

  status = pthread_attr_setstacksize( &attr, stacksize );
  assert( !status );

  status = pthread_create( &thread_id, &attr, start_gnat_main, NULL );
  assert( !status );

  pthread_exit( 0 );

  return 0;
}

/* configuration information */

#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER

#define CONFIGURE_MICROSECONDS_PER_TICK RTEMS_MILLISECONDS_TO_MICROSECONDS(1)

/* ACATS needs to be able to create files */
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20

#define CONFIGURE_POSIX_INIT_THREAD_TABLE

#define CONFIGURE_MAXIMUM_SEMAPHORES 10
#define CONFIGURE_GNAT_RTEMS
#define CONFIGURE_MAXIMUM_ADA_TASKS      20
#define CONFIGURE_MAXIMUM_FAKE_ADA_TASKS 0

#define CONFIGURE_MEMORY_OVERHEAD        (256 + GNAT_MAIN_STACKSPACE)

#define CONFIGURE_INIT

#include <confdefs.h>



--------------C0682C92A969A813F2F40526
Content-Type: text/plain; charset=us-ascii;
 name="native.cfg"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="native.cfg"

# Configuration file for native compilation

target_setup () {
  return 0
}

target_gnatmake () {
  time gnatmake $* -largs $EXTERNAL_OBJECTS
}

target_gcc () {
  time gcc $*
}

target_run () {
  time $*
}



--------------C0682C92A969A813F2F40526
Content-Type: text/plain; charset=us-ascii;
 name="erc32.cfg"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="erc32.cfg"

# Configuration file for native compilation

target_setup () {
  cp $dir/config/rtems_init.c  $dir/work/support
  return 0
}

RTEMS_CPU_ARGS="-B /opt/gnatrtems/sparc-rtems/erc32/lib/ -specs bsp_specs -qrtems -mcpu=cypress"

target_gnatmake () {
  time sparc-rtems-gnatmake -v $* \
    -bargs -Mgnat_main \
    -cargs ${RTEMS_CPU_ARGS} \
    -largs ${RTEMS_CPU_ARGS} $dir/work/support/rtems_init.o $EXTERNAL_OBJECTS
}

target_gcc () {
  time sparc-rtems-gcc ${RTEMS_CPU_ARGS} $*
}

target_run () {
( echo "load $*" ; 
  echo "go 0x02000000 0x40000000" ;
  echo "quit" )> $dir/work/support/sis-script
  time sparc-rtems-sis -c $dir/work/support/sis-script $*
}



--------------C0682C92A969A813F2F40526--

