예제 #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
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
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
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)
}