Add missing symlink-related Open tests

Adds some tests related to symlinks and Open() that were accidentally
omitted in earlier CLs.

Bug: 436025865
Change-Id: I088ca709f75bdbac79f32c4633652eabb19167f4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/276602
Commit-Queue: Brian Sheedy <bsheedy@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
diff --git a/tools/src/oswrapper/fstestoswrapper_test.go b/tools/src/oswrapper/fstestoswrapper_test.go
index fc124be..a3672e9 100644
--- a/tools/src/oswrapper/fstestoswrapper_test.go
+++ b/tools/src/oswrapper/fstestoswrapper_test.go
@@ -488,6 +488,52 @@
 				wantErrMsg: "not a directory",
 			},
 		},
+		{
+			name: "Open symlink to file",
+			path: filepath.Join(root, "link_to_file"),
+			setup: unittestSetup{
+				initialFiles: map[string]string{filepath.Join(root, "file.txt"): "symlink content"},
+				initialSymlinks: map[string]string{
+					filepath.Join(root, "link_to_file"): "file.txt",
+				},
+			},
+			expectedContent: stringPtr("symlink content"),
+		},
+		{
+			name: "Open symlink to directory",
+			path: filepath.Join(root, "link_to_dir"),
+			setup: unittestSetup{
+				initialDirs: []string{filepath.Join(root, "dir")},
+				initialSymlinks: map[string]string{
+					filepath.Join(root, "link_to_dir"): "dir",
+				},
+			},
+		},
+		{
+			name: "Open broken symlink",
+			path: filepath.Join(root, "broken_link"),
+			setup: unittestSetup{
+				initialSymlinks: map[string]string{
+					filepath.Join(root, "broken_link"): "nonexistent",
+				},
+			},
+			expectedError: expectedError{
+				wantErrIs: os.ErrNotExist,
+			},
+		},
+		{
+			name: "Open symlink loop",
+			path: filepath.Join(root, "loop1"),
+			setup: unittestSetup{
+				initialSymlinks: map[string]string{
+					filepath.Join(root, "loop1"): "loop2",
+					filepath.Join(root, "loop2"): "loop1",
+				},
+			},
+			expectedError: expectedError{
+				wantErrIs: syscall.ELOOP,
+			},
+		},
 	}
 
 	for _, tc := range tests {
@@ -548,6 +594,45 @@
 			}},
 			path: filepath.Join("file.txt", "another.txt"),
 		},
+		{
+			name: "Open symlink to file",
+			setup: matchesRealSetup{unittestSetup{
+				initialFiles: map[string]string{"file.txt": "symlink content"},
+				initialSymlinks: map[string]string{
+					"link_to_file": "file.txt",
+				},
+			}},
+			path: "link_to_file",
+		},
+		{
+			name: "Open symlink to directory",
+			setup: matchesRealSetup{unittestSetup{
+				initialDirs: []string{"dir"},
+				initialSymlinks: map[string]string{
+					"link_to_dir": "dir",
+				},
+			}},
+			path: "link_to_dir",
+		},
+		{
+			name: "Open broken symlink",
+			setup: matchesRealSetup{unittestSetup{
+				initialSymlinks: map[string]string{
+					"broken_link": "nonexistent",
+				},
+			}},
+			path: "broken_link",
+		},
+		{
+			name: "Open symlink loop",
+			setup: matchesRealSetup{unittestSetup{
+				initialSymlinks: map[string]string{
+					"loop1": "loop2",
+					"loop2": "loop1",
+				},
+			}},
+			path: "loop1",
+		},
 	}
 
 	for _, tc := range tests {
@@ -738,6 +823,20 @@
 			},
 		},
 		{
+			name: "Error - Open symlink to directory for writing",
+			path: filepath.Join(root, "link_to_dir"),
+			flag: os.O_WRONLY,
+			setup: unittestSetup{
+				initialDirs: []string{filepath.Join(root, "dir")},
+				initialSymlinks: map[string]string{
+					filepath.Join(root, "link_to_dir"): "dir",
+				},
+			},
+			expectedError: expectedError{
+				wantErrMsg: "is a directory",
+			},
+		},
+		{
 			name: "Open symlink to file",
 			path: filepath.Join(root, "link_to_file"),
 			flag: os.O_RDONLY,
@@ -986,6 +1085,17 @@
 			flag: os.O_WRONLY,
 		},
 		{
+			name: "Error - Open symlink to directory for writing",
+			setup: matchesRealSetup{unittestSetup{
+				initialDirs: []string{"dir"},
+				initialSymlinks: map[string]string{
+					"link_to_dir": "dir",
+				},
+			}},
+			path: "link_to_dir",
+			flag: os.O_WRONLY,
+		},
+		{
 			name: "Open symlink to file",
 			setup: matchesRealSetup{unittestSetup{
 				initialFiles: map[string]string{"file.txt": "content"},