Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

Commit

Permalink
tests: check current working directory
Browse files Browse the repository at this point in the history
Add a new test to check that the WorkingDirectory specified in the ACI
manifest is used.
  • Loading branch information
alban authored and iaguis committed May 23, 2016
1 parent 65e6e68 commit 3a779ef
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
11 changes: 4 additions & 7 deletions tests/inspect/inspect.go
Expand Up @@ -47,7 +47,7 @@ var (
PrintCapsPid int
PrintUser bool
PrintGroups bool
CheckCwd string
PrintCwd bool
ExitCode int
ReadFile bool
WriteFile bool
Expand Down Expand Up @@ -83,7 +83,7 @@ func init() {
globalFlagset.BoolVar(&globalFlags.PrintExec, "print-exec", false, "Print the command we were execed as (i.e. argv[0])")
globalFlagset.StringVar(&globalFlags.PrintMsg, "print-msg", "", "Print the message given as parameter")
globalFlagset.StringVar(&globalFlags.SuffixMsg, "suffix-msg", "", "Print this suffix after some commands")
globalFlagset.StringVar(&globalFlags.CheckCwd, "check-cwd", "", "Check if the current working directory is the one specified")
globalFlagset.BoolVar(&globalFlags.PrintCwd, "print-cwd", false, "Print the current working directory")
globalFlagset.StringVar(&globalFlags.PrintEnv, "print-env", "", "Print the specified environment variable")
globalFlagset.IntVar(&globalFlags.PrintCapsPid, "print-caps-pid", -1, "Print capabilities of the specified pid (or current process if pid=0)")
globalFlagset.BoolVar(&globalFlags.PrintUser, "print-user", false, "Print uid and gid")
Expand Down Expand Up @@ -285,16 +285,13 @@ func main() {
fmt.Printf("%s: group: %v\n", fileName, fi.Sys().(*syscall.Stat_t).Gid)
}

if globalFlags.CheckCwd != "" {
if globalFlags.PrintCwd {
wd, err := os.Getwd()
if err != nil {
fmt.Fprintf(os.Stderr, "Cannot get working directory: %v\n", err)
os.Exit(1)
}
if wd != globalFlags.CheckCwd {
fmt.Fprintf(os.Stderr, "Working directory: %q. Expected: %q.\n", wd, globalFlags.CheckCwd)
os.Exit(1)
}
fmt.Printf("cwd: %s\n", wd)
}

if globalFlags.Sleep >= 0 {
Expand Down
22 changes: 22 additions & 0 deletions tests/rkt_run_pod_manifest_test.go
Expand Up @@ -119,6 +119,28 @@ func TestPodManifest(t *testing.T) {
`'"[$]`,
"",
},
{
// Working directory.
[]imagePatch{
{"rkt-test-run-pod-manifest-working-directory.aci", []string{}},
},
&schema.PodManifest{
Apps: []schema.RuntimeApp{
{
Name: baseAppName,
App: &types.App{
Exec: []string{"/inspect", "--print-cwd"},
User: "0",
Group: "0",
WorkingDirectory: "/dir1",
},
},
},
},
0,
"cwd: /dir1",
"",
},
{
// Simple read.
[]imagePatch{
Expand Down

0 comments on commit 3a779ef

Please sign in to comment.