1 #
   2 # CDDL HEADER START
   3 #
   4 # The contents of this file are subject to the terms of the
   5 # Common Development and Distribution License (the "License").
   6 # You may not use this file except in compliance with the License.
   7 #
   8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 
  22 #
  23 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 
  27 
  28 # OPEN nfsv4 C program assertions
  29 
  30 Note: cache invalidation is by means similar to those used in
  31   Cthon - lock suite.
  32 
  33 Open Scenarios:
  34 The following test scenario is run with (exhaustive) combinations of
  35 parameters obtained from the following sets:
  36 
  37 mode={0600 0400 0200 000)
  38 oflags={O_EXCL|O_RDWR  O_RDWR  O_WRONLY  O_RDONLY}
  39 
  40 Scenario A)
  41  prep) All done by the parent (before spawning a child)
  42   - open file1 (fd_i) with mode 600 and oflags O_CREAT|O_TRUNC|O_RDWR
  43   - using fd_i, write a test message, chmod to right mode
  44 
  45  Assertions:
  46  a) Parent open file1 (get fd1) with provided parameters oflag and mode.
  47   Expect OK when mode=0600, {mode, oflags}={0400, O_RDONLY} |
  48    {0200, O_WRONLY}. Else expect EACCES.
  49  -prep) Parent use dup to get a second fd (fd2) on same file1. Expect
  50   same results as previous assertion. If operation successful, then
  51   forks a child, else finish this scenario (no fds available to continue).
  52  b) close fd1 on parent (expect OK), then wait for child next step
  53  c) child verifies if it can write & read using fd1 and fd2.
  54   READ Expect OK when: mode = 0600 & oflags != O_WRONLY,
  55    mode = 0400 & oflags = O_RDONLY. Else, expect EBADF
  56   WRITE Expect OK when: mode = 0600 & oflags != O_RDONLY,
  57    mode = 0200 & oflags = O_WRONLY. Else, expect EBADF
  58  d) verify if parent can read fds 1 and 2 wait for child next step.
  59   Expect EBADF for fd1, and same results as in previous step for fd2
  60  e) close fds 1 & 2 on child and sleep for long time.
  61  f) verify if parent can read fds 1 and 2, then kills child.
  62   Expect same results as in step (d).
  63  g) verify if parent can read fds 1 and 2, then close fd2.
  64   Expect same results as in step (d).
  65 
  66  clean) - close fd_i
  67   - unlink file1
  68 
  69 Note 1) all writes and reads are preceded by lseek to offset 0,
  70  unless specified
  71 Note 2) if environment var SYNCWRITE is defined, writes are followed
  72  by fsync() and invalidating the cache and a read on fd_i to compare
  73  data on server. And reads are preceded by invalidating the cache
  74  to force read from server.
  75 
  76 To test hard links
  77 The following test scenario is run with (exhaustive) combinations of
  78  parameters obtained from the following sets:
  79 
  80 mode={0600 0400 0200 000)
  81 oflags={O_EXCL|O_RDWR  O_RDWR  O_WRONLY  O_RDONLY}
  82 
  83 Scenario B)
  84  prep) All done by the parent (before spawning a child)
  85   - open file1 (fd_i) with mode 600 and oflags O_CREAT|O_TRUNC|O_RDWR
  86   - using fd_i, write a test message
  87   - link file1 to file2 (hard link)
  88 
  89  Assertions:
  90  a) Parent open file1 (get fd1) with provided parameters oflag and mode.
  91   Expect OK when mode=0600, {mode, oflags}={0400, O_RDONLY} |
  92    {0200, O_WRONLY}. Else expect EACCES.
  93  b) Parent opens (fd2) file2 (hard link) with same parameters used in file1.
  94   Expect same results as with file1
  95   If operation successful, then forks a child,
  96   else finish this scenario (no fds available to continue).
  97  c) close fd1 on parent (expect OK), then wait for child next step
  98  d) child verifies if it can write & read using fd1 and fd2.
  99   READ Expect OK when: mode = 0600 & oflags != O_WRONLY,
 100    mode = 0400 & oflags = O_RDONLY. Else, expect EBADF
 101   WRITE Expect OK when: mode = 0600 & oflags != O_RDONLY,
 102    mode = 0200 & oflags = O_WRONLY. Else, expect EBADF
 103  e) verify if parent can read fds 1 and 2 wait for child next step.
 104   Expect EBADF for fd1, and same results as in previous step for fd2
 105  f) close fds 1 & 2 on child and sleep for long time.
 106  g) verify if parent can read fds 1 and 2, then kills child.
 107   Expect same results as in step (e).
 108  h) verify if parent can read fds 1 and 2, then close fd2.
 109   Expect same results as in step (e).
 110 
 111  clean) - close fd_i
 112   - unlink file1
 113 
 114 Note 1) all writes and reads are preceded by lseek to offset 0, unless
 115  specified
 116 Note 2) if environment var SYNCWRITE is defined, writes are followed
 117  by fsync() and invalidating the cache and a read on fd_i to compare
 118  data on server. And reads are preceded by invalidating the cache
 119  to force read from server.
 120 
 121 Scenario C)
 122  change for mode={0660 0600 0440 0400 0220 0200 000)
 123 
 124  prep) All done by the parent (before spawning a child)
 125   - open file1 (fd_i) with mode 600 and oflags O_CREAT|O_TRUNC|O_RDWR
 126   - using fd_i, write a test message
 127   - link file1 to file2 (hard link)
 128 
 129  Assertions:
 130  a) Parent open file1 (get fd1) with provided parameters oflag and mode.
 131   Expect OK when mode=0660, {mode, oflags}={0440, O_RDONLY} |
 132    {0220, O_WRONLY}. Else expect EACCES.
 133  b) Parent opens (fd2) file2 (hard link) with same parameters used in file1.
 134   Expect same results as with file1
 135  c) Parent use dup() to create fd3 to same file, expect OK when fd1 is
 136 valid,
 137   else EBADF.
 138   If operation successful, then forks a child,
 139   else finish this scenario (no fds available to continue).
 140  d) close fd1 on parent (expect OK), then wait for child next step
 141  e) child verifies if it can write & read using fd1, fd2 and fd3, after
 142   changing UID with setuid (GID is the same).
 143   READ Expect EBADF when mode = 0X00,
 144        Expect OK when: mode = 0660 & oflags != O_WRONLY,
 145    mode = 0440 & oflags = O_RDONLY. Else, expect EBADF
 146   WRITE Expect EBADF when mode = 0X00,
 147         Expect OK when: mode = 0660 & oflags != O_RDONLY,
 148    mode = 0220 & oflags = O_WRONLY. Else, expect EBADF
 149  e) child verifies if it can write & read using fd1, fd2 and fd3, after
 150   changing GID with setgid.
 151   READ Expect EBADF
 152   WRITE EBADF
 153 
 154  clean) - close all remaining fds
 155   - parent kills the child
 156   - unlink file1
 157 
 158 Note 1) all writes and reads are preceded by lseek to offset 0, unless
 159  specified
 160 Note 2) if environment var SYNCWRITE is defined, writes are followed
 161  by fsync() and invalidating the cache and a read on fd_i to compare
 162  data on server. And reads are preceded by invalidating the cache
 163  to force read from server.
 164 
 165 Scenario D)
 166  prep) All done by the parent (before spawning a child)
 167   - open file1 (fd_i) with mode 600 and oflags O_CREAT|O_TRUNC|O_RDWR
 168   - using fd_i, write a test message
 169   - link file1 to file2 (hard link)
 170 
 171  Assertions:
 172  a) Parent changes file permissions for file1 to 000, then forks a file.
 173  b) Child tries to open file1 (try O_RDWR | O_RDONLY | O_WRONLY), expect
 174 EACCES
 175  c) Child tries to open file2 (try O_RDWR | O_RDONLY | O_WRONLY), expect
 176 EACCES
 177 
 178  clean) - close all remaining fds
 179   - parent kills the child
 180   - unlink file1
 181 
 182 Note 1) all writes and reads are preceded by lseek to offset 0, unless
 183  specified
 184 Note 2) if environment var SYNCWRITE is defined, writes are followed
 185  by fsync() and invalidating the cache and a read on fd_i to compare
 186  data on server. And reads are preceded by invalidating the cache
 187  to force read from server.
 188 
 189 Scenario E)
 190 this is the single test case for bug  5092786 ,it is different from the other
 191 above.
 192 
 193 Assertions:
 194  a) Parent open a file with O_CREAT option,then reopen it with O_TRUNC option.
 195  this is to test client's OPEN upgrade. 
 196 The client should upgrade its OPEN modes for the open/truncate.