From 1de5ceed586335361baae02160d61400fbf71e15 Mon Sep 17 00:00:00 2001
From: Jakob Unterwurzacher
Date: Sun, 26 Jun 2016 18:34:30 +0200
Subject: tests: add missing file "example_test_helpers.go"

This file was forgotten in commit
"tests: make tests for unsupported FSs more compact".
---
 tests/example_filesystems/example_test_helpers.go | 69 +++++++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 tests/example_filesystems/example_test_helpers.go

diff --git a/tests/example_filesystems/example_test_helpers.go b/tests/example_filesystems/example_test_helpers.go
new file mode 100644
index 0000000..e4c03ad
--- /dev/null
+++ b/tests/example_filesystems/example_test_helpers.go
@@ -0,0 +1,69 @@
+package example_filesystems
+
+import (
+	"io/ioutil"
+	"os"
+	"path/filepath"
+	"testing"
+
+	"github.com/rfjakob/gocryptfs/tests/test_helpers"
+)
+
+// checkExampleFS - verify that "dir" contains the expected test files
+func checkExampleFS(t *testing.T, dir string, rw bool) {
+	// Read regular file
+	statusFile := filepath.Join(dir, "status.txt")
+	contentBytes, err := ioutil.ReadFile(statusFile)
+	if err != nil {
+		t.Fatal(err)
+	}
+	content := string(contentBytes)
+	if content != statusTxtContent {
+		t.Errorf("Unexpected content: %s\n", content)
+	}
+	// Read relative symlink
+	symlink := filepath.Join(dir, "rel")
+	target, err := os.Readlink(symlink)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if target != "status.txt" {
+		t.Errorf("Unexpected link target: %s\n", target)
+	}
+	// Read absolute symlink
+	symlink = filepath.Join(dir, "abs")
+	target, err = os.Readlink(symlink)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if target != "/a/b/c/d" {
+		t.Errorf("Unexpected link target: %s\n", target)
+	}
+
+	if rw {
+		// Test directory operations
+		test_helpers.TestRename(t, dir)
+		test_helpers.TestMkdirRmdir(t, dir)
+	}
+}
+
+// checkExampleFSLongnames - verify that "dir" contains the expected test files
+// plus the long file name test file
+func checkExampleFSLongnames(t *testing.T, dir string) {
+	// regular tests
+	checkExampleFS(t, dir, true)
+	// long name test file
+	longname := "longname_255_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +
+		"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +
+		"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +
+		"xxxxxxxxxxxxxxxxxxxxxxxx"
+	contentBytes, err := ioutil.ReadFile(filepath.Join(dir, longname))
+	if err != nil {
+		t.Fatal(err)
+	}
+	content := string(contentBytes)
+	if content != statusTxtContent {
+		t.Errorf("longname_255: unexpected content: %s\n", content)
+	}
+
+}
-- 
cgit v1.2.3