Commit be680e18 authored by Aaron Jacobs's avatar Aaron Jacobs

Fixed StatFSTest.CapacityAndFreeSpace on Linux.

parent ca114f29
......@@ -16,6 +16,7 @@ package statfs_test
import (
"fmt"
"regexp"
"syscall"
"github.com/jacobsa/fuse/fuseops"
......@@ -23,6 +24,13 @@ import (
. "github.com/jacobsa/ogletest"
)
// Sample output:
//
// Filesystem 1024-blocks Used Available Capacity iused ifree %iused Mounted on
// fake@bucket 32 16 16 50% 0 0 100% /Users/jacobsa/tmp/mp
//
var gDfOutputRegexp = regexp.MustCompile(`^\S+\s+(\d+)\s+(\d+)\s+(\d+)\s+\d+%\s+\d+\s+\d+\s+\d+%.*$`)
////////////////////////////////////////////////////////////////////////
// Helpers
////////////////////////////////////////////////////////////////////////
......
......@@ -17,12 +17,20 @@ package statfs_test
import (
"fmt"
"math"
"regexp"
"syscall"
"github.com/jacobsa/fuse/fuseops"
. "github.com/jacobsa/ogletest"
)
// Sample output:
//
// Filesystem 1K-blocks Used Available Use% Mounted on
// some_fuse_file_system 512 64 384 15% /tmp/sample_test001288095
//
var gDfOutputRegexp = regexp.MustCompile(`^\S+\s+(\d+)\s+(\d+)\s+(\d+)\s+\d+%.*$`)
////////////////////////////////////////////////////////////////////////
// Tests
////////////////////////////////////////////////////////////////////////
......
......@@ -21,7 +21,6 @@ import (
"os/exec"
"path"
"path/filepath"
"regexp"
"runtime"
"strconv"
"testing"
......@@ -44,13 +43,6 @@ func TestStatFS(t *testing.T) { RunTests(t) }
// system's. The output is not guaranteed to have resolution greater than 2^10
// (1 KiB).
func df(dir string) (capacity, used, available uint64, err error) {
// Sample output:
//
// Filesystem 1024-blocks Used Available Capacity iused ifree %iused Mounted on
// fake@bucket 32 16 16 50% 0 0 100% /Users/jacobsa/tmp/mp
//
re := regexp.MustCompile(`^\S+\s+(\d+)\s+(\d+)\s+(\d+)\s+\d+%\s+\d+\s+\d+\s+\d+%.*$`)
// Call df with a block size of 1024 and capture its output.
cmd := exec.Command("df", dir)
cmd.Env = []string{"BLOCKSIZE=1024"}
......@@ -67,7 +59,7 @@ func df(dir string) (capacity, used, available uint64, err error) {
continue
}
submatches := re.FindSubmatch(line)
submatches := gDfOutputRegexp.FindSubmatch(line)
if submatches == nil {
err = fmt.Errorf("Unable to parse line: %q", line)
return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment