#!/usr/bin/expect -f

# Automatically setup and compile the test suites

# This is $Revision: 1.11 $
#
# $Log: auto_configure_test_suites,v $
# Revision 1.11  2004/05/05 08:08:32  cyeoh
# changes for test suite config changes
#
# Revision 1.10  2003/07/29 14:58:00  cyeoh
# use system version of expect
#
# Revision 1.9  2003/07/28 22:44:53  cyeoh
# bump up timeout for time allowed to enter root password
#
# Revision 1.8  2003/07/28 21:46:46  cyeoh
# bump up timeouts for slow machines
#
# Revision 1.7  2003/04/07 06:46:02  cyeoh
# explicitly state cc so TET searches through the path
# for the compiler as on some platforms now the compiler to
# use is not in /usr/bin
#
# Revision 1.6  2003/03/03 03:00:57  cyeoh
# update build script to handle extra FHS question
#
# Revision 1.5  2002/11/21 03:38:50  cyeoh
# changes for introduction of vsthlite and li8nux test suites into lsb-runtime-test
#
# Revision 1.4  2002/10/23 10:43:18  cyeoh
# Configure to use LSB version of expect
#
# Revision 1.3  2001/11/27 03:36:13  cyeoh
# Root password entering is now interactive instead of hardcoded to support
# easier build of RPMS
# Fixes problem with loopback filesystem scripting
#
# Revision 1.2  2001/11/22 07:32:45  cyeoh
# cleanup
#
# This is Revision 1.1  2001/11/22 07:10:13  cyeoh
# This is Initial checkin
# 

# Root password
set timeout 600
stty -echo
send_user "This script needs to know the root password during various\n"
send_user "stages of the build process. This bit does need user interaction\n"
send_user "and is NOT scripted\n"
send_user {Enter the root password: }
expect_user -re "(.*)\n"
send_user "\n"
stty echo
set root_password $expect_out(1,string)

# Misc configuration
set cfg_name Automated
set cfg_agency NONE
set cfg_system UNKNOWN

# Expect wrapper
# Expect a simple string and send a return carriage if its received
proc simple_expect_or_die { expect_string } {
#    regsub -all "([\[\]])" $expect_string "\\$1" $expect_string
    expect -ex $expect_string { send "\n" } \
        timeout { puts "expected \"$expect_string\" but never came."; exit 1 }
}



spawn /bin/sh -c ../setup.sh

# Loopback disk setup
set timeout 1200
expect {Building/Installing test sets} { set timeout 10 }
expect -ex {Create loopback disk?} {send "\n"} \
  timeout { }
simple_expect_or_die {Setup loopback disk? [y] }
set timeout 3
simple_expect_or_die {Enter loopback device to use [/dev/loop0]}
set timeout 600
expect -ex {Password: } { sleep 2; send "$root_password\r" }


# config.sh configuration
simple_expect_or_die {Run config.sh ..? [y] }
simple_expect_or_die {installation procedure }
simple_expect_or_die {Which test mode do you require}
simple_expect_or_die {Which subsets do you wish to install}

expect {What is your name} { send "$cfg_name\n" }
expect "What is the agency for whom you are running VSX" { send "$cfg_agency\n" }
expect "What is the system on which you are running VSX" { send "$cfg_system\n" }

simple_expect_or_die {testsets will be executed}
simple_expect_or_die {How fast is your machine}
simple_expect_or_die {The system include directories}

expect {UNIX98 registration runs} { send "cc\n" }

simple_expect_or_die {What command line options does your C compiler need}

simple_expect_or_die {What link editor options does your C compiler need }
simple_expect_or_die {There are no additional libraries needed to compile VSX}
simple_expect_or_die {linking programs that use threads and real time features}
simple_expect_or_die {only Realtime APIs}
simple_expect_or_die {Base APIs (including Threads APIs) and Realtime APIs}
simple_expect_or_die {Are dependencies between shared objects supported (y/n)}
simple_expect_or_die {Are shared objects containing unresolved references supported}
simple_expect_or_die {What compiler options are used instead of the normal options when}
simple_expect_or_die {What link editor options are used instead of the normal options }
simple_expect_or_die {Which library is your dynamic linking library }
simple_expect_or_die {Which library is your pthreads library}
simple_expect_or_die {Which other libraries are needed to build VSTH}
simple_expect_or_die {What command line options does your C compiler need}
simple_expect_or_die {Which command line option does your C compiler use to create a pure}
simple_expect_or_die {Which library is your maths library}
simple_expect_or_die {What is the mountable device to be used for ENOSPC testing}

# Pseudo languages
simple_expect_or_die {Install pseudolanguages}
expect "Password: " { sleep 2; send "$root_password\n" }

# Making harness
expect "Password: " { sleep 2; send "$root_password\n" }
set timeout 1200
simple_expect_or_die {Install scripts into TESTROOT/BIN..?}
simple_expect_or_die {Use pax..?}
simple_expect_or_die {Install nonexistent devices ..?}
expect "Password: " { sleep 2; send "$root_password\n" }
simple_expect_or_die {Install tetexec.cfg}

expect "Build and Execute testsets" { send "n\n" }
