~john-koepi/ubuntu/trusty/golang/default

« back to all changes in this revision

Viewing changes to src/pkg/os/os_test.go

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-08-03 17:04:59 UTC
  • mfrom: (14.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110803170459-wzd99m3567y80ila
Tags: 1:59-1
* Imported Upstream version 59
* Refresh patches to a new release
* Fix FTBFS on ARM (Closes: #634270)
* Update version.bash to work with Debian packaging and not hg
  repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
359
359
}
360
360
 
361
361
func TestHardLink(t *testing.T) {
362
 
        // Hardlinks are not supported under windows.
363
 
        if syscall.OS == "windows" {
 
362
        // Hardlinks are not supported under windows or Plan 9.
 
363
        if syscall.OS == "windows" || syscall.OS == "plan9" {
364
364
                return
365
365
        }
366
366
        from, to := "hardlinktestfrom", "hardlinktestto"
392
392
}
393
393
 
394
394
func TestSymLink(t *testing.T) {
395
 
        // Symlinks are not supported under windows.
396
 
        if syscall.OS == "windows" {
 
395
        // Symlinks are not supported under windows or Plan 9.
 
396
        if syscall.OS == "windows" || syscall.OS == "plan9" {
397
397
                return
398
398
        }
399
399
        from, to := "symlinktestfrom", "symlinktestto"
454
454
}
455
455
 
456
456
func TestLongSymlink(t *testing.T) {
457
 
        // Symlinks are not supported under windows.
458
 
        if syscall.OS == "windows" {
 
457
        // Symlinks are not supported under windows or Plan 9.
 
458
        if syscall.OS == "windows" || syscall.OS == "plan9" {
459
459
                return
460
460
        }
461
461
        s := "0123456789abcdef"
588
588
}
589
589
 
590
590
func TestChown(t *testing.T) {
591
 
        // Chown is not supported under windows.
592
 
        if syscall.OS == "windows" {
 
591
        // Chown is not supported under windows or Plan 9.
 
592
        // Plan9 provides a native ChownPlan9 version instead.
 
593
        if syscall.OS == "windows" || syscall.OS == "plan9" {
593
594
                return
594
595
        }
595
596
        // Use TempDir() to make sure we're on a local file system,
708
709
                t.Fatalf("second Stat %s: %s", f.Name(), err)
709
710
        }
710
711
 
711
 
        if postStat.Atime_ns >= preStat.Atime_ns {
 
712
        /* Plan 9:
 
713
                Mtime is the time of the last change of content.  Similarly, atime is set whenever the
 
714
            contents are accessed; also, it is set whenever mtime is set.
 
715
        */
 
716
        if postStat.Atime_ns >= preStat.Atime_ns && syscall.OS != "plan9" {
712
717
                t.Errorf("Atime_ns didn't go backwards; was=%d, after=%d",
713
718
                        preStat.Atime_ns,
714
719
                        postStat.Atime_ns)
733
738
        // These are chosen carefully not to be symlinks on a Mac
734
739
        // (unlike, say, /var, /etc, and /tmp).
735
740
        dirs := []string{"/", "/usr/bin"}
 
741
        // /usr/bin does not usually exist on Plan 9.
 
742
        if syscall.OS == "plan9" {
 
743
                dirs = []string{"/", "/usr"}
 
744
        }
736
745
        for mode := 0; mode < 2; mode++ {
737
746
                for _, d := range dirs {
738
747
                        if mode == 0 {
858
867
                        t.Errorf("Open(%q, %d) returns error of %T type; want *os.PathError", tt.path, tt.mode, err)
859
868
                }
860
869
                if perr.Error != tt.error {
861
 
                        t.Errorf("Open(%q, %d) = _, %q; want %q", tt.path, tt.mode, perr.Error.String(), tt.error.String())
 
870
                        if syscall.OS == "plan9" {
 
871
                                syscallErrStr := perr.Error.String()
 
872
                                expectedErrStr := strings.Replace(tt.error.String(), "file ", "", 1)
 
873
                                if !strings.HasSuffix(syscallErrStr, expectedErrStr) {
 
874
                                        t.Errorf("Open(%q, %d) = _, %q; want suffix %q", tt.path, tt.mode, syscallErrStr, expectedErrStr)
 
875
                                }
 
876
                        } else {
 
877
                                t.Errorf("Open(%q, %d) = _, %q; want %q", tt.path, tt.mode, perr.Error.String(), tt.error.String())
 
878
                        }
862
879
                }
863
880
        }
864
881
}
893
910
 
894
911
func TestHostname(t *testing.T) {
895
912
        // There is no other way to fetch hostname on windows, but via winapi.
896
 
        if syscall.OS == "windows" {
 
913
        // On Plan 9 it is can be taken from #c/sysname as Hostname() does.
 
914
        if syscall.OS == "windows" || syscall.OS == "plan9" {
897
915
                return
898
916
        }
899
917
        // Check internal Hostname() against the output of /bin/hostname.
1024
1042
                t.Fatal("stat failed:", err)
1025
1043
        }
1026
1044
}
 
1045
 
 
1046
func TestNilWaitmsgString(t *testing.T) {
 
1047
        var w *Waitmsg
 
1048
        s := w.String()
 
1049
        if s != "<nil>" {
 
1050
                t.Errorf("(*Waitmsg)(nil).String() = %q, want %q", s, "<nil>")
 
1051
        }
 
1052
}