SibylFS: formal specification and oracle-based testing
for POSIX and real-world filesystems

Tom Ridge

2015-04-21
(with Thomas Tuerk, David Sheets, Andrea Giugliano, Anil Madhavapeddy, Peter Sewell; talk at Cambridge REMS meeting; 20 mins talk+10 mins qus)

Overview

What have we done?

How does everything fit together?

System structure

Example test script

A test script is essentially a list of libc calls to execute on a real-world system

 @type script
 #####################################
 # Test link___link_nonempty_dir1__d2__sl_dotdot_d2___nonempty_dir1__nonexist_4
 #####################################
 mkdir "empty_dir1" 0o777
 mkdir "empty_dir2" 0o777
 mkdir "nonempty_dir1" 0o777
 mkdir "nonempty_dir1/d2" 0o777
 open "nonempty_dir1/d2/f3.txt" [O_CREAT;O_WRONLY] 0o666
 write! (FD 3) "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor inc" 83
 close (FD 3)
 ... // further setup commands
 link "nonempty_dir1/d2/sl_dotdot_d2" "nonempty_dir1/nonexist_4"
 ...

Example trace (behaviour of real-world system)

A trace records the libc calls from the test script, and the responses received from the real-world system

# processing file 'link___link_nonempty_dir1__d2__sl_dotdot_d2___nonempty_dir1__nonexist_4-int.trace' ...
        @type trace
        #####################################
        # Test link___link_nonempty_dir1__d2__sl_dotdot_d2___nonempty_dir1__nonexist_4
        #####################################
     5: mkdir "empty_dir1" 0o777
        Tau
        RV_none
     6: mkdir "empty_dir2" 0o777
        Tau
        RV_none
     7: mkdir "nonempty_dir1" 0o777
        Tau
        RV_none
     8: mkdir "nonempty_dir1/d2" 0o777
        Tau
        RV_none
     9: open "nonempty_dir1/d2/f3.txt" [O_CREAT;O_WRONLY] 0o666
        Tau
        RV_num(3)
    10: write! (FD 3) "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor inc" 83
        Tau
        RV_num(83)

...

    28: link "nonempty_dir1/d2/sl_dotdot_d2" "nonempty_dir1/nonexist_4"
        Tau
        RV_none

...

Example checked trace

The specification

The specification

HTML version of main file here

Form of the specification: LTS

  type os_label =  
    | OS_CALL of (ty_pid * ty_os_command)
    | OS_RETURN of (ty_pid * error_or_value ret_value)
    | OS_CREATE of (ty_pid * uid * gid)
    | OS_DESTROY of ty_pid
    | OS_TAU
  type ty_os_command = 
    | OS_CLOSE of ty_fd                                         (* per-process file descriptors *)
    | OS_LINK of (cstring * cstring)                            (* hard links *)
    | OS_MKDIR of (cstring * file_perm)                         (* cstring can include null *)
    | OS_OPEN of (cstring * int_open_flags * maybe file_perm)   (* open flags as fixed-width int, platform specific encoding *)
    | OS_PREAD of (ty_fd * size_t * off_t) 
    | OS_READ of (ty_fd * size_t) 
    | OS_READDIR of ty_dh
    | OS_OPENDIR of cstring
    | OS_REWINDDIR of ty_dh
    | OS_CLOSEDIR of ty_dh
    | OS_READLINK of cstring                                    (* symlinks *)
    | OS_RENAME of (cstring * cstring)
    | OS_RMDIR of cstring
    | OS_STAT of cstring
    | OS_LSTAT of cstring
    | OS_SYMLINK of (cstring * cstring) 
    | OS_TRUNCATE of (cstring * off_t)
    | OS_UNLINK of cstring
    | OS_PWRITE of (ty_fd * ty_bytes * size_t * off_t)
    | OS_WRITE of (ty_fd * ty_bytes * size_t) 
    | OS_UMASK of file_perm                                     (* permissions *) 
    | OS_CHMOD of (cstring * file_perm)
    | OS_CHOWN of (cstring * uid * gid)                         (* users, groups *)
    | OS_CHDIR of cstring                                       (* model of per-process state *)
    | OS_LSEEK of (ty_fd * off_t * int_seek_command)
    | ...

The main challenges when writing the spec

The complexity of real-world behaviour

Testing

Testing

Test oracle enables combinatorial testing

Use of LTS for testing real-world systems

Difficulty of LTS trace checking

Test results, stats

Test results, strange behaviours

Testing summary

Conclusion

Possible uses of the spec

Future work