Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Levin Zimmermann
go-fuse
Commits
408ce31f
Commit
408ce31f
authored
Mar 21, 2013
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unionfs: skip rm -rf test if rm is older than v. 8.0
parent
f0d19206
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
3 deletions
+40
-3
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+40
-3
No files found.
unionfs/unionfs_test.go
View file @
408ce31f
package
unionfs
package
unionfs
import
(
import
(
"bytes"
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
"log"
"log"
"os"
"os"
"os/exec"
"os/exec"
"path/filepath"
"path/filepath"
"regexp"
"strings"
"strings"
"strconv"
"syscall"
"syscall"
"testing"
"testing"
"time"
"time"
...
@@ -98,7 +101,7 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) {
...
@@ -98,7 +101,7 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) {
return
wd
,
func
()
{
return
wd
,
func
()
{
err
:=
state
.
Unmount
()
err
:=
state
.
Unmount
()
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
setRecursiveWritable
(
t
,
wd
,
true
)
setRecursiveWritable
(
t
,
wd
,
true
)
os
.
RemoveAll
(
wd
)
os
.
RemoveAll
(
wd
)
...
@@ -893,8 +896,34 @@ func TestUnionFsRemoveAll(t *testing.T) {
...
@@ -893,8 +896,34 @@ func TestUnionFsRemoveAll(t *testing.T) {
}
}
}
}
// Warning: test fails under coreutils < 8.0 because of non-posix behaviour
func
ProgramVersion
(
bin
string
)
(
major
,
minor
int64
,
err
error
)
{
// of the "rm" tool -- which relies on behaviour that doesn't work in fuse.
cmd
:=
exec
.
Command
(
bin
,
"--version"
)
buf
:=
&
bytes
.
Buffer
{}
cmd
.
Stdout
=
buf
if
err
:=
cmd
.
Run
();
err
!=
nil
{
return
0
,
0
,
err
}
lines
:=
strings
.
Split
(
buf
.
String
(),
"
\n
"
)
if
len
(
lines
)
<
1
{
return
0
,
0
,
fmt
.
Errorf
(
"no output"
)
}
matches
:=
regexp
.
MustCompile
(
".* ([0-9]+)
\\
.([0-9]+)"
)
.
FindStringSubmatch
(
lines
[
0
])
if
matches
==
nil
{
log
.
Println
(
"no output"
)
return
0
,
0
,
fmt
.
Errorf
(
"no match for %q"
,
lines
[
0
])
}
major
,
err
=
strconv
.
ParseInt
(
matches
[
1
],
10
,
64
)
if
err
!=
nil
{
return
0
,
0
,
err
}
minor
,
err
=
strconv
.
ParseInt
(
matches
[
2
],
10
,
64
)
if
err
!=
nil
{
return
0
,
0
,
err
}
return
major
,
minor
,
nil
}
func
TestUnionFsRmRf
(
t
*
testing
.
T
)
{
func
TestUnionFsRmRf
(
t
*
testing
.
T
)
{
wd
,
clean
:=
setupUfs
(
t
)
wd
,
clean
:=
setupUfs
(
t
)
defer
clean
()
defer
clean
()
...
@@ -916,6 +945,14 @@ func TestUnionFsRmRf(t *testing.T) {
...
@@ -916,6 +945,14 @@ func TestUnionFsRmRf(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"LookPath failed: %v"
,
err
)
t
.
Fatalf
(
"LookPath failed: %v"
,
err
)
}
}
maj
,
min
,
err
:=
ProgramVersion
(
bin
)
if
err
!=
nil
{
t
.
Logf
(
"ProgramVersion failed: %v"
,
err
)
}
if
maj
<
8
{
// assuming GNU coreutils.
t
.
Skipf
(
"Skipping test; GNU rm %d.%d is not POSIX compliant."
,
maj
,
min
)
}
command
:=
fmt
.
Sprintf
(
"%s -f %s/mnt/dir"
,
bin
,
wd
)
command
:=
fmt
.
Sprintf
(
"%s -f %s/mnt/dir"
,
bin
,
wd
)
log
.
Printf
(
"Command: %s"
,
command
)
log
.
Printf
(
"Command: %s"
,
command
)
names
,
_
:=
Readdirnames
(
wd
+
"/mnt/dir"
)
names
,
_
:=
Readdirnames
(
wd
+
"/mnt/dir"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment