set pdsh "$objdir/src/pdsh/pdsh"

#expect_after {
#	timeout				{ unresolved "$test" }
#	eof				{ unresolved "$test" }
#}

# This is required for the following test to work but I have no idea
# why. Let's blame DejaGNU.
#expect eof

set test "pdsh: version (if this fails beware that testsuite is outdated)"
spawn $pdsh -V
expect  {
	-re "pdsh-2.10"		        { pass "$test" }
	eof				{ fail "$test" }
}

set test "pdsh: xstrerrorcat obtains text for errnos (gnats:35)"
spawn $pdsh -T 0
expect  {
	-re ".*PASS"			{ pass "$test" }
	-re ".*FAIL"			{ fail "$test" }
	-re ".*UNSUPPORTED"		{ unsupported "$test" }
	-re ".*unknown"			{ unsupported "$test" }
}

set test "pdsh: hostname range expansion works"
spawn  $pdsh -Qw foo\[0-3\]
expect  {
	-re "foo0,foo1,foo2,foo3" 	{ pass "$test" }
	eof	 			{ fail "$test" }
}

set test "pdsh: hostname range expansion does not strip leading zeros"
spawn $pdsh -Qw foo\[00-02\]
expect  {
	-re "foo00,foo01,foo02"		{ pass "$test" }
	eof	 			{ fail "$test" }
}

set test "pdsh: hostname range expansion handles mixed size suffixes"
spawn $pdsh -Qw "foo\[9-11\]"
expect  {
	-re "foo9,foo10,foo11"		{ pass "$test" }
	eof	 			{ fail "$test" }
}

set test "pdsh: hostname range expansion works with ',' embedded in range"
spawn $pdsh -Qw foo\[0-2,4\] 
expect  {
	-re "foo0,foo1,foo2,foo4"	{ pass "$test" }
	eof				{ fail "$test" }
}

set test "pdsh: -x option works"
spawn $pdsh -Qw foo\[9-11\] -x foo10
expect  {
	-re "foo9,foo11"		{ pass "$test" }
	eof	 			{ fail "$test" }
}

set test "pdsh: -x option works with ranges (gnats:118)"
spawn $pdsh -Qw foo\[0-5\] -x foo\[1-3\]
expect  {
	-re "foo0,foo4,foo5"		{ pass "$test" }
	eof				{ fail "$test" }
}

set test "pdsh: -x option works with non-numeric suffixes (gnats:120)"
spawn $pdsh -Qw fooi,fooj,foo\[0-5\] -x fooj,fooi,foo2
expect  {
	-re "foo0,foo1,foo3,foo4,foo5"	{ pass "$test" }
	eof				{ fail "$test" }
}


set test "pdsh: ranges can be embedded in wcoll files"
spawn $pdsh -Qw-
send "foo\[9-11\]\n"
send \004
expect  {
	-re "foo9,foo10,foo11"		{ pass "$test" }
	eof	 			{ fail "$test" }
}
