[yast-commit] r59984 - in /trunk/storage/storage/src/testsuite: ./ config/ lib/ run/ tests/ tests_propose/
Author: aschnell Date: Mon Dec 7 16:45:41 2009 New Revision: 59984 URL: http://svn.opensuse.org/viewcvs/yast?rev=59984&view=rev Log: - started work on testsuite for storage proposal Added: trunk/storage/storage/src/testsuite/Makefile.am trunk/storage/storage/src/testsuite/lib/test.exp trunk/storage/storage/src/testsuite/lib/test_init.exp trunk/storage/storage/src/testsuite/run/ trunk/storage/storage/src/testsuite/run/runtest.sh (with props) trunk/storage/storage/src/testsuite/tests/proposal1.err trunk/storage/storage/src/testsuite/tests/proposal1.out trunk/storage/storage/src/testsuite/tests/proposal1.ycp Removed: trunk/storage/storage/src/testsuite/tests/auto_part_functions.ycp trunk/storage/storage/src/testsuite/tests/runtest.sh trunk/storage/storage/src/testsuite/tests/test_inst_target_part.ycp trunk/storage/storage/src/testsuite/tests_propose/ Modified: trunk/storage/storage/src/testsuite/config/unix.exp Added: trunk/storage/storage/src/testsuite/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/testsuite/Makefile.am?rev=59984&view=auto ============================================================================== --- trunk/storage/storage/src/testsuite/Makefile.am (added) +++ trunk/storage/storage/src/testsuite/Makefile.am Mon Dec 7 16:45:41 2009 @@ -0,0 +1,21 @@ +# +# Makefile.am for .../testsuite +# +# Do not edit this file (Makefile.am) as it will be overwritten! +# + +AUTOMAKE_OPTIONS = dejagnu +EXTRA_DIST = $(wildcard tests/*.out) $(wildcard tests/*.err) $(wildcard tests/*.ycp) $(wildcard tests/*.yh) + +testsuite_prepare = @ydatadir@/testsuite/Makefile.testsuite + +all-local: $(testsuite_prepare) + make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) + +clean-local: $(testsuite_prepare) + make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) clean + +check-local: $(testsuite_prepare) + make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) check + +# EOF Modified: trunk/storage/storage/src/testsuite/config/unix.exp URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/testsuite/config/unix.exp?rev=59984&r1=59983&r2=59984&view=diff ============================================================================== --- trunk/storage/storage/src/testsuite/config/unix.exp (original) +++ trunk/storage/storage/src/testsuite/config/unix.exp Mon Dec 7 16:45:41 2009 @@ -1,5 +1,114 @@ -load_lib "partitioning_init.exp" +# YaST2: modules testsuite +# +# Description: +# Main config file +# +# Author: +# Michal Svec <msvec@suse.cz> +# +# $Id$ -proc partitioning_exit {} {} -proc partitioning_version {} {} +proc testsuite_exit {} {} +proc testsuite_version {} {} +# Run one test + +proc testsuite-run { src } { + + set path [split $src "/"] + set filename [lindex $path [expr [llength $path]-1]] + + # extract basename and check extension + + set fname [split $filename "."] + + if {[llength $fname] < 2} { + fail "Bad filename syntax '$src'" + return -1 + } + if {[lindex $fname [expr [llength $fname]-1]] != "ycp"} { + fail "Not .ycp extension '$src'" + return -1 + } + + # setup filenames + + # $src is the name of the original testfile with absolute path + # tests/$filename is the name of the original testfile with relative path, + # relative to the testsuite directory + set test_input "tests/$filename" + + set base_name [lindex $fname 0] + + set stdout_name "tests/$base_name.out" + set stderr_name "tests/$base_name.err" + set log_name "tests/$base_name.log" + set tmpout_name "tmp.out.$base_name" + set tmperr_name "tmp.err.$base_name" + set tmplog_name "tmp.log.$base_name" + + # fate#2306: enable make check *gasp* before make install + # by searching in the source directory + set options "" + # first hack: look for the usual suspects + # (next steps: use YCPCFLAGS) + set sourcedir "../src" + if {[file isdirectory $sourcedir]} { + set options "-I $sourcedir -M $sourcedir" + } + + puts "Running $base_name ..." + + # run the test + + set result "" + set oops [catch { set result [exec "run/runtest.sh" $options "$test_input" "$tmpout_name" "$tmperr_name" ] } catched] + + if {$oops != 0} { + fail "Test case failed for $base_name: $catched" + return -1 + } + + # check return code from runycp + + if {$result != ""} { + warning "Compilation of $base_name results in '$result'" + return -1 + } + + # check stderr + + if {[diff $stderr_name "tmp.err.$base_name"] != 1} { + fail "Wrong stderr for $base_name" + set oops [catch { set result [exec test -f $stderr_name] } catched ] + if {$oops == 0} { + puts "\nThe diff follows...\n" + puts [exec sh -c "diff -u $stderr_name tmp.err.$base_name || true"] + puts "" + fail "Wrong stderr for $base_name" + puts "See the diff above." + } + return -1 + } + + # check stdout + + if {[diff $stdout_name "tmp.out.$base_name"] != 1} { + fail "Wrong stdout for $base_name" + set oops [catch { set result [exec test -f $stdout_name] } catched ] + if {$oops == 0} { + puts "\nThe diff follows...\n" + puts [exec sh -c "diff -u $stdout_name tmp.out.$base_name || true"] + puts "" + fail "Wrong stdout for $base_name" + puts "See the diff above." + } + return -1 + } + + # ok, all is fine + + pass $base_name + + return 0 +} Added: trunk/storage/storage/src/testsuite/lib/test.exp URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/testsuite/lib/test.exp?rev=59984&view=auto ============================================================================== --- trunk/storage/storage/src/testsuite/lib/test.exp (added) +++ trunk/storage/storage/src/testsuite/lib/test.exp Mon Dec 7 16:45:41 2009 @@ -0,0 +1 @@ +# anyagent.exp -- empty Added: trunk/storage/storage/src/testsuite/lib/test_init.exp URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/testsuite/lib/test_init.exp?rev=59984&view=auto ============================================================================== --- trunk/storage/storage/src/testsuite/lib/test_init.exp (added) +++ trunk/storage/storage/src/testsuite/lib/test_init.exp Mon Dec 7 16:45:41 2009 @@ -0,0 +1,68 @@ +# +# run a anyagent file +# +proc anyagent-run { src } { + + set path [split $src "/"] + set filename [lindex $path [expr [llength $path]-1]] + + # extract basename and check extension + + set fname [split $filename "."] + + if {[llength $fname] < 2} { + fail "Bad filename syntax '$src'" + return + } + if {[lindex $fname [expr [llength $fname]-1]] != "anyagent"} { + fail "Not .anyagent extension '$src'" + return + } + + # setup filenames + + set base_name [lindex $fname 0] + + set stdout_name "tests/$base_name.out" + set stderr_name "tests/$base_name.err" + set tmpout_name "tmp.out.$base_name" + set tmperr_name "tmp.err.$base_name" + # run the test + + puts "Running $base_name..." + + set result "" + set oops [catch { set result [exec "../anyagent" "stdio" "anyagent" "<$src" ">$tmpout_name" "2>$tmperr_name"] } catched] + + if {$oops != 0} { + fail "y2anyagent failed: $catched" + return + } + + # check return code from y2anyagent + + if {$result != ""} { + warning "Compilation of $base_name results in '$result'" + return + } + + # check stdout + + if {[diff $stdout_name $tmpout_name] != 1} { + fail "Wrong stdout for $base_name" + return + } + + # check stderr +# D I S A B L E D +# if {[diff $stderr_name $tmperr_name] != 1} { +# fail "Wrong stderr for $base_name" +# return +# } +# + # ok, all is fine + + pass $base_name + + return +} Added: trunk/storage/storage/src/testsuite/run/runtest.sh URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/testsuite/run/runtest.sh?rev=59984&view=auto ============================================================================== --- trunk/storage/storage/src/testsuite/run/runtest.sh (added) +++ trunk/storage/storage/src/testsuite/run/runtest.sh Mon Dec 7 16:45:41 2009 @@ -0,0 +1,94 @@ +#! /bin/bash + +# Run test on one ycp file +# Michal Svec <msvec@suse.cz> +# +# $1 = script.ycp +# $2 = stdout +# $3 = stderr +# +# These arguments may be preceded by options that will be passed to y2base +# +# $Id: runtest.sh 46223 2008-04-08 11:09:51Z mvidner $ + +while [ $# -gt 3 ]; do + OPTIONS="$OPTIONS $1" + shift +done + +unset LANG +unset LC_CTYPE +unset LC_NUMERIC +unset LC_TIME +unset LC_COLLATE +unset LC_MONETARY +unset LC_MESSAGES +unset LC_PAPER +unset LC_NAME +unset LC_ADDRESS +unset LC_TELEPHONE +unset LC_MEASUREMENT +unset LC_IDENTIFICATION +unset LC_ALL + +unset Y2DEBUG +unset Y2DEBUGALL +# export Y2DEBUG=1 +# export Y2DEBUGALL=1 +export Y2ALLGLOBAL=1 + +ybindir=`pkg-config --print-errors --variable=ybindir yast2-devtools` +yast2dir=`pkg-config --print-errors --variable=yast2dir yast2-devtools` +Y2BASE=$ybindir/y2base +logconf="$yast2dir/data/testsuite/log.conf" + +if [ ! -f "$logconf" ]; then + logconf="../skel/log.conf" +fi + +DUMMY_LOG_STRING="LOGTHIS_SECRET_314 " + +files="$(grep '^[/*[:space:]]*testedfiles:' "$1"|sed 's/.*testedfiles:[[:space:]]*//g')" +if [ "$files" ]; then + echo "$files" >> testsuite.log + regex="[ /](testsuite\.ycp|Testsuite\.ycp|$(echo "$files"|sed 's|\.|\\.|g'|sed 's| |\||g')):" +fi +echo "$regex" >> testsuite.log + +parse() { + file="`mktemp /tmp/yast2-test.XXXXXX`" + cat >"$file" + if [ -z "$Y2TESTSUITE" ]; then + # errors are OK if they come from YCP (or Perl, #41448), + # mark them for output + sed1="s/ <[2-5]> [^ ]\+ \[\(YCP\|Perl\)\] \([^ ]\+\) / <0> host [YCP] \2 ${DUMMY_LOG_STRING}Log /" + # leave only essential info + sed2="s/^.*$DUMMY_LOG_STRING//g" + ycp="\[YCP\].*$DUMMY_LOG_STRING" + components="(agent-dummy|YCP)" + cat "$file" | sed "$sed1" | grep -E "<[012]>[^]]*$components.*$regex.*$DUMMY_LOG_STRING" | sed "$sed2" # | cut -d" " -f7- + # Y2PMrc: #38235 + cat "$file" | grep "<[345]>" | grep -v "\[\(YCP\|Perl\|Y2PMrc\)\]" >&2 + else + echo "Y2TESTSUITE set to \"$Y2TESTSUITE\"" + echo + cat "$file" + fi + rm -f "$file" +} + +( $Y2BASE -l - -c "$logconf" $OPTIONS "$1" UI 2>&1 ) | parse >"$2" 2>"$3" + +retcode="$PIPESTATUS" +if [ "$retcode" -gt 0 ]; then + if [ "$retcode" -ge 128 ]; then + sig=$[$retcode-128] + echo -ne "\nCommand terminated on signal '$sig'" + echo -e '!\n' + else + echo -e "\nReturn code: '$retcode'.\n" + fi +fi + +exit "$retcode" +# EOF Added: trunk/storage/storage/src/testsuite/tests/proposal1.err URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/testsuite/tests/proposal1.err?rev=59984&view=auto ============================================================================== (empty) Added: trunk/storage/storage/src/testsuite/tests/proposal1.out URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/testsuite/tests/proposal1.out?rev=59984&view=auto ============================================================================== (empty) Added: trunk/storage/storage/src/testsuite/tests/proposal1.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/testsuite/tests/proposal1.ycp?rev=59984&view=auto ============================================================================== --- trunk/storage/storage/src/testsuite/tests/proposal1.ycp (added) +++ trunk/storage/storage/src/testsuite/tests/proposal1.ycp Mon Dec 7 16:45:41 2009 @@ -0,0 +1,60 @@ +{ + include "testsuite.ycp"; + + map READ = $[ + "probe" : $[ + "architecture" : "i385", + "cdrom" : [] + ], + "proc" : $[ + "swaps" : [] + ], + "sysconfig" : $[ + "storage" : $[ + "DEFAULT_FS" : "ext4" + ], + "bootloader" : $[ + "LOADER_TYPE" : "grub" + ], + "language" : $[ + "RC_LANG" : "en_US.UTF-8", + "RC_LC_MESSAGES" : "", + ], + ], + "target" : $[ + "size" : 0, + "bash_output" : $[], + "yast2" : $[], + "dir" : [], + ], + ]; + + TESTSUITE_INIT([READ, $[], READ], nil); + + + import "Storage"; + import "StorageProposal"; + + map<string, map> target_map = Storage::GetTargetMap(); + + map<string, any> prop = StorageProposal::get_inst_prop(target_map); + + if (prop["ok"]:false) + { + Storage::SetTargetMap(prop["target"]:$[]); + + list<map> infos = Storage::GetCommitInfos(); + + DUMP("Proposal:"); + foreach(map info, infos, { + string text = info["text"]:""; + if (info["destructive"]:false) + text = text + " [destructive]"; + DUMP(text); + }); + } + else + { + DUMP("No proposal."); + } +} -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
aschnell@svn.opensuse.org