Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Run-eunit-loop.expect

The Run-eunit-loop.expect script is a work-around for a number of
problems that I ran into when using PULSE adn the bitcask_eqc.erl
test model.  It's a mess and could really use a refactoring, but
it does what I needed it to....

Before identifying the cause of SIGSEGV and "Bad tag" aborts,
I wanted to automatically restart testing if the test failed for
either reason.  Ditto for deadlock and timeout problems within
PULSE itself.  The timeout problems have been quite mysterious,
but as far as I can tell it isn't a problem with the bitcask
code.  I would run rebar with network distributed enabled, then
attach to it via "erl -remsh rebar@localhost" and use Redbug to
watch for calls to bitcask, bitcask_nifs, bitcask_lockops, and
bitcask_fileops when one of the timeouts happened ... and there
were zero calls to those functions.

The most common problem I see, as of this commit, are "Invariant
broken" errors, e.g.,

     Invariant broken, <0.28726.1> did send at {"c_src/bitcask_nifs.c",1718} when 'handle_info.WorkerPid' is supposed to be the only running process!!

If I change pulse_send() so that we send messages directly to
their recipient (instead of the PULSE controller), then I see
PULSE timeout errors instead of invariant errors.  {shrug}

Another PULSE problem that I'd see in the past were things
like this:

    =ERROR REPORT==== 10-Nov-2012::17:43:40 ===
    Unknown command for pulse: loaded
    =ERROR REPORT==== 11-Nov-2012::21:31:43 ===
    Unknown command for pulse: [code_server|{module,pulse_gen_server}]
    =ERROR REPORT==== 4-Nov-2012::21:47:14 ===
    Unknown command for pulse: {11,<<121,48,236,98,2,156,137,137,27,144,44>>}
    Unknown command for pulse: [{root,yield},
                                {root,yield},
                                {root,yield},
                                .......
  • Loading branch information...
commit 6e58a374763a097dc5bd8c80d5da7fa73d60a426 1 parent b350fb5
@slfritchie slfritchie authored
Showing with 113 additions and 1 deletion.
  1. +1 −1  .gitignore
  2. +112 −0 priv/Run-eunit-loop.expect
View
2  .gitignore
@@ -1,6 +1,6 @@
.eunit/*
deps/*
ebin
-priv/*
+priv/*.so
*.o
*.beam
View
112 priv/Run-eunit-loop.expect
@@ -0,0 +1,112 @@
+#!/usr/bin/expect --
+
+## usage: $0 eunit-command-as-a-single-string
+
+## Reminder reminder reminder: never use single quotes
+## Reminder reminder reminder: never use single quotes
+## Reminder reminder reminder: never use single quotes
+
+set default_timeout 120
+set timeout $default_timeout
+match_max -d 200100100
+
+set eunit_command [lindex $argv 0]
+set threshold [lindex $argv 1]
+set sleeptime [lindex $argv 2]
+
+spawn bash
+set main_session $spawn_id
+
+proc msg_to_user {msg} {
+ send_user "\n\n*** [exec date] $msg\r\n"
+}
+
+proc echo_and_say {msg} {
+ msg_to_user $msg
+ spawn say "$msg"
+ expect eof
+ upvar 1 main_session main_session
+ set spawn_id $main_session
+}
+
+proc wait_for_shell_prompt {} {
+ # My bash shell prompt looks like this: "bash-3.2$ "
+ set bash_prompt_string "bash"
+ expect $bash_prompt_string
+}
+
+msg_to_user "Now starting"
+set count 0
+while {1} {
+ send "$eunit_command\r"
+ incr count
+ msg_to_user "Running number $count"
+ while {1} {
+ expect {
+ {Segmentation} {
+ echo_and_say "Segmentation violation"
+ puts "cp /tmp/slf-stuff-just-in-case ./zzz.sigsegv.[exec date +%s]"
+ exec cp /tmp/slf-stuff-just-in-case ./zzz.sigsegv.[exec date +%s]
+ sleep 2
+ wait_for_shell_prompt ; echo_and_say "Got prompt"
+ break
+ }
+ {size_object} {
+ echo_and_say "Bad tag"
+ puts "cp /tmp/slf-stuff-just-in-case ./zzz.bad-tag.[exec date +%s]"
+ exec cp /tmp/slf-stuff-just-in-case ./zzz.bad-tag.[exec date +%s]
+ sleep 2
+ wait_for_shell_prompt ; echo_and_say "Got prompt"
+ break
+ }
+ {deadlock} {
+ echo_and_say "Deadlock"
+ send "\003" ; sleep 1; send "\003" ; sleep 1;
+ wait_for_shell_prompt ; echo_and_say "Got prompt"
+ break
+ }
+ {Invariant broken} {
+ msg_to_user "Invariant broken"
+ #puts "cp /tmp/slf-stuff-just-in-case ./zzz.invariant-broken.[exec date +%s]"
+ #exec cp /tmp/slf-stuff-just-in-case ./zzz.invariant-broken.[exec date +%s]
+ send "\003" ; sleep 1; send "\003" ; sleep 1;
+ wait_for_shell_prompt ; # echo_and_say "Got prompt"
+ break
+ }
+ {Shrinking} {
+ echo_and_say "Bad joss, Taipan. We are shrinking"
+ set timeout 9999999
+ }
+ {Unknown command for pulse} {
+ set timeout $default_timeout
+ echo_and_say "Drat, unknown command for pulse"
+ puts "cp /tmp/slf-stuff-just-in-case ./zzz.unknown-command.[exec date +%s]"
+ exec cp /tmp/slf-stuff-just-in-case ./zzz.unknown-command.[exec date +%s]
+ send "\003" ; sleep 1; send "\003" ; sleep 1;
+ wait_for_shell_prompt ; echo_and_say "Got prompt"
+ break;
+ }
+ {ERROR:} {
+ send_user "Exiting now"
+ echo_and_say "Run finished, please check output"
+ exit 1
+ }
+ {Test passed} {
+ wait_for_shell_prompt ; echo_and_say "Hooray, test passed"
+ exit 0
+ }
+ timeout {
+ echo_and_say "Bummer, there was a timeout"
+ puts "cp /tmp/slf-stuff-just-in-case ./zzz.timeout.[exec date +%s]"
+ exec cp /tmp/slf-stuff-just-in-case ./zzz.timeout.[exec date +%s]
+ # set foo 15 ; sleep 2 ; echo_and_say "I am going to sleep for $foo seconds to allow a control-z to suspend and debug" ; sleep $foo
+ send "\003\r" ; sleep 1; send "\003\r" ; sleep 1;
+ wait_for_shell_prompt ; echo_and_say "Got prompt"
+ break
+ }
+ {.} {
+ send_user "~"
+ }
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.