コード例 #1
0
ファイル: updates.go プロジェクト: dholbach/snappy
func buildSnap(c *check.C, snapDir, targetDir string) {
	// build in /var/tmp (which is not a tempfs)
	cmds, _ := cli.AddOptionsToCommand([]string{
		"sudo", "TMPDIR=/var/tmp", "snappy", "build", "--squashfs", snapDir,
	})
	cmd := exec.Command(cmds[0], cmds[1:]...)
	cmd.Dir = targetDir
	cli.ExecCommandWrapper(cmd)
}
コード例 #2
0
ファイル: login_test.go プロジェクト: dholbach/snappy
func (s *loginSuite) writeCredentials(loginName string) error {
	cmds, _ := cli.AddOptionsToCommand([]string{"sudo", "snap", "login", loginName})
	cmd := exec.Command(cmds[0], cmds[1:]...)
	f, err := pty.Start(cmd)
	if err != nil {
		return err
	}

	err = cmdInteract(f, "Password: ", password)
	if err != nil {
		return err
	}
	io.Copy(&s.stdout, f)

	return nil
}
コード例 #3
0
ファイル: examples_test.go プロジェクト: dholbach/snappy
func (s *licensedExampleSuite) TestDeclineLicenseMustNotInstallSnap(c *check.C) {
	c.Skip("port to snapd")

	cmds := []string{"sudo", "snappy", "install", "licensed.canonical/edge"}
	cmdsCover, err := cli.AddOptionsToCommand(cmds)
	c.Assert(err, check.IsNil, check.Commentf("Error adding coverage options, %q", err))

	cmd := exec.Command(cmdsCover[0], cmdsCover[1:]...)
	f, err := pty.Start(cmd)
	c.Assert(err, check.IsNil, check.Commentf("Error starting pty: %s", err))

	s.assertLicense(c, f)
	// Decline the license.
	_, err = f.Write([]byte("n\n"))
	c.Assert(err, check.IsNil, check.Commentf("Error writing to pty: %s", err))

	cmd.Wait()

	c.Assert(s.isSnapInstalled(c), check.Equals, false, check.Commentf("The snap was installed"))
}
コード例 #4
0
ファイル: console_test.go プロジェクト: dholbach/snappy
func (s *consoleSuite) SetUpTest(c *check.C) {
	s.SnappySuite.SetUpTest(c)

	c.Skip("FIXME: port to snap")

	var err error

	cmdsIn := []string{"snappy", "console"}
	cmdsOut, err := cli.AddOptionsToCommand(cmdsIn)
	c.Assert(err, check.IsNil, check.Commentf("Error adding coverage options, %q", err))

	s.cmd = exec.Command(cmdsOut[0], cmdsOut[1:]...)
	s.stdin, err = s.cmd.StdinPipe()
	c.Assert(err, check.IsNil, check.Commentf("Expected nil error, got %s", err))
	s.stdout, err = s.cmd.StdoutPipe()
	c.Assert(err, check.IsNil, check.Commentf("Expected nil error, got %s", err))

	s.outbr = bufio.NewReader(s.stdout)

	err = s.cmd.Start()
	c.Assert(err, check.IsNil, check.Commentf("Expected nil error, got %s", err))

	s.checkPrompt(c)
}