//
// Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
//
// This test will use the following files:
//
ctf stf ls_to_copy ctest.c
fcntl open_test truncate rd wf 
set_region set_return_on_destroy 
--------------------------------------------
// These setup commands are run before the daemon starts.
// They reset the file structure of the test directory
// to a known state.
//
rm $real_dir/???
$1/ctf $1 $real_dir
$1/stf $1 $real_dir/l??
chown $lname $real_dir/l??
$1/set_return_on_destroy $real_dir test
--------------------------------------------
@@ Aborted events testing (1 of 7):
@@    Bring ls0 across NFS, causing it to be cached.
@@
$1/open_test $2/ls0 o_rdwr
event_count 1
event[0] read
--------------------------------------------
@@ Aborted events testing (2 of 7):
@@    Set the daemon to halt events with DM_RESP_ABORT
@@    and errno EEXIST. 
@@
run_as_root
$1/send_msg unfriendly_17
event_count 1
event[0] user
msg_str[0] unfriendly_17
--------------------------------------------
@@ Aborted events testing (3 of 7):
@@    Try to read ls0.  Since it is cached, this should succeed.
@@    and should not generate any events.
@@
$1/open_test $2/ls0 o_rdwr
event_count 0
--------------------------------------------
@@ Aborted events testing (4 of 7):
@@    Try to read ls1.  This should fail with EEXIST.
@@
$1/open_test $2/ls1 o_rdwr o_trunc
event_count 1
event[0] truncate
failure
--------------------------------------------
@@ Aborted events testing (5 of 7):
@@    Reset the daemon to respond with DM_RESP_CONTINUE.
@@
run_as_root
$1/send_msg friendly
event_count 1
event[0] user
msg_str[0] friendly
--------------------------------------------
@@ Aborted events testing (6 of 7):
@@    Again, try to read ls0.  It will be in the cache, 
@@    so no events should occur.
@@
$1/open_test $2/ls0 o_rdwr
event_count 0
--------------------------------------------
@@ Aborted events testing (7 of 7):
@@    Again, try to read ls1.  This time, 
@@    it should succeed.
@@
$1/open_test $2/ls1 o_rdwr o_trunc
event_count 2
event[0] truncate
event[1] attribute
--------------------------------------------
@@ dm_send_msg test
@@
run_as_root
$1/send_msg dmapi-test-foo-abc123
event_count 1
event[0] user
msg_str[0] dmapi-test-foo-abc123
--------------------------------------------
@@ NFS test:  DM_RESP_ABORT (1 of 3)
@@
// For the next two events, respond with
// DM_RESP_ABORT and errno 4  The first 
// open test of ls1 should fail; the
// second should succeed.
//
run_as_root
$1/send_msg countdown_2_4
event_count 1
event[0] user
msg_str[0] countdown_2_4
--------------------------------------------
@@ NFS test:  DM_RESP_ABORT (2 of 3)
@@
$1/open_test $2/ls2 o_rdwr
event_count 1
event[0] read
failure
--------------------------------------------
@@ NFS test:  DM_RESP_ABORT (3 of 3)
@@
$1/open_test $2/ls2 o_rdwr
event_count 1
event[0] read
--------------------------------------------
@@ NFS test:  EAGAIN (1 of 4)
@@
// For the next two events, respond with
// DM_RESP_ABORT and errno 11 -- EAGAIN.
// NFS should retry sending the event as
// long as EAGAIN is returned.
//
run_as_root
$1/send_msg countdown_2_11
event_count 1
event[0] user
msg_str[0] countdown_2_11
--------------------------------------------
@@ NFS test:  EAGAIN (2 of 4)
@@
$1/open_test $2/ls3 o_rdwr
event_count 2
event[0] read
event[1] read
--------------------------------------------
@@ NFS test:  EAGAIN (3 of 4)
@@
run_as_root
$1/send_msg countdown_4_11
event_count 1
event[0] user
msg_str[0] countdown_4_11
--------------------------------------------
@@ NFS test:  EAGAIN (4 of 4)
@@
$1/open_test $2/ls4 o_rdwr
event_count 4
event[0] read
event[1] read
event[2] read
event[3] read
