当前位置: 首页>>代码示例>>Golang>>正文


Golang cli.ExecCommand函数代码示例

本文整理汇总了Golang中github.com/ubuntu-core/snappy/integration-tests/testutils/cli.ExecCommand函数的典型用法代码示例。如果您正苦于以下问题:Golang ExecCommand函数的具体用法?Golang ExecCommand怎么用?Golang ExecCommand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ExecCommand函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: SetUpSuite

// SetUpSuite disables the snappy autopilot. It will run before all the
// integration suites.
func (s *SnappySuite) SetUpSuite(c *check.C) {
	var err error
	Cfg, err = config.ReadConfig(
		"integration-tests/data/output/testconfig.json")
	c.Assert(err, check.IsNil, check.Commentf("Error reading config: %v", err))

	if !IsInRebootProcess() {
		if Cfg.Update || Cfg.Rollback {
			// TODO handle updates to a different release and channel.
			// Always use the installed snappy because we are updating from an old
			// image, so we should not use the snappy from the branch.
			output := cli.ExecCommand(c, "sudo", "/usr/bin/snappy", "update")
			// TODO raise an error if there is no available update.
			if output != "" {
				RebootWithMark(c, "setupsuite-update")
			}
		}
	} else if CheckRebootMark("setupsuite-update") {
		RemoveRebootMark(c)
		// Update was already executed. Update the config so it's not triggered again.
		Cfg.Update = false
		Cfg.Write()
		if Cfg.Rollback {
			cli.ExecCommand(c, "sudo", "snappy", "rollback", partition.OSSnapName(c))
			RebootWithMark(c, "setupsuite-rollback")
		}
	} else if CheckRebootMark("setupsuite-rollback") {
		RemoveRebootMark(c)
		// Rollback was already executed. Update the config so it's not triggered again.
		Cfg.Rollback = false
		Cfg.Write()
	}
}
开发者ID:robert-ancell,项目名称:snapd,代码行数:35,代码来源:common.go

示例2: TestAppUpdate

func (s *snapRefreshAppSuite) TestAppUpdate(c *check.C) {
	c.Skip("port to snapd")

	snap := "hello-world.canonical"
	storeSnap := fmt.Sprintf("%s", snap)

	// install edge version from the store (which is squshfs)
	cli.ExecCommand(c, "sudo", "snap", "install", storeSnap)
	defer cli.ExecCommand(c, "sudo", "snap", "remove", snap)

	// make a fakestore and make it available to snapd

	// use /var/tmp is not a tempfs for space reasons
	blobDir, err := ioutil.TempDir("/var/tmp", "snap-fake-store-blobs-")
	c.Assert(err, check.IsNil)
	defer cli.ExecCommand(c, "sudo", "rm", "-rf", blobDir)

	fakeStore := store.NewStore(blobDir)
	err = fakeStore.Start()
	c.Assert(err, check.IsNil)
	defer fakeStore.Stop()

	env := fmt.Sprintf(`SNAPPY_FORCE_CPI_URL=%s`, fakeStore.URL())
	cfg, _ := config.ReadConfig(config.DefaultFileName)
	tearDownSnapd(cfg.FromBranch)
	setUpSnapd(c, cfg.FromBranch, env)

	// run the fake update
	output := updates.CallFakeSnapRefresh(c, snap, updates.NoOp, fakeStore)
	c.Assert(output, check.Matches, "(?ms).*^hello-world.*fake1.*")
}
开发者ID:dholbach,项目名称:snappy,代码行数:31,代码来源:snap_update_app_test.go

示例3: TestAutoUpdateMessageIsPrinted

// Test that there is a proper message if autoupdate runs in the
// background
func (s *autoupdateMsgSuite) TestAutoUpdateMessageIsPrinted(c *check.C) {
	cli.ExecCommand(c, "sudo", "systemctl", "start", "snappy-autopilot")

	s.AddCleanup(func() {
		cli.ExecCommand(c, "sudo", "systemctl", "stop", "snappy-autopilot")
		// do not pollute the other tests with hello-world, in case it is installed
		_, err := exec.Command("sudo", "snappy", "remove", "hello-world").CombinedOutput()
		if err != nil {
			fmt.Println("hello-world didn't get installed")
		}
	})

	// FIXME: risk of race
	// (i.e. systemctl start finishes before install runs)
	snappyOutput, _ := exec.Command("sudo", "snappy", "install", "hello-world").CombinedOutput()

	var expectedTxt string
	if common.Release(c) == "15.04" {
		expectedTxt = "another snappy is running, try again later"
	} else {
		expectedTxt = "Snappy is updating your system"
	}
	expectedPattern := "(?ms).*^" + expectedTxt + ".*\n.*"

	c.Assert(string(snappyOutput), check.Matches, expectedPattern)
}
开发者ID:General-Beck,项目名称:snappy,代码行数:28,代码来源:autoupdate-msg_test.go

示例4: SetUpSuite

// SetUpSuite disables the snappy autopilot. It will run before all the
// integration suites.
func (s *SnappySuite) SetUpSuite(c *check.C) {
	var err error
	Cfg, err = config.ReadConfig(config.DefaultFileName)
	c.Assert(err, check.IsNil, check.Commentf("Error reading config: %v", err))

	if !IsInRebootProcess() {
		if Cfg.Update || Cfg.Rollback {
			// TODO handle updates to a different release and channel.
			// Always use the installed snappy because we are updating from an old
			// image, so we should not use the snappy from the branch.
			output := cli.ExecCommand(c, "sudo", "/usr/bin/snappy", "update")
			expected := "(?ms)" +
				".*" +
				fmt.Sprintf("^Reboot to use %s version .*\\.\n", partition.OSSnapName(c))
			c.Assert(output, check.Matches, expected)
			RebootWithMark(c, "setupsuite-update")
		}
	} else if CheckRebootMark("setupsuite-update") {
		RemoveRebootMark(c)
		// Update was already executed. Update the config so it's not triggered again.
		Cfg.Update = false
		Cfg.Write()
		if Cfg.Rollback {
			cli.ExecCommand(c, "sudo", "snappy", "rollback", partition.OSSnapName(c))
			RebootWithMark(c, "setupsuite-rollback")
		}
	} else if CheckRebootMark("setupsuite-rollback") {
		RemoveRebootMark(c)
		// Rollback was already executed. Update the config so it's not triggered again.
		Cfg.Rollback = false
		Cfg.Write()
	}
}
开发者ID:dholbach,项目名称:snappy,代码行数:35,代码来源:common.go

示例5: SetUpSuite

// SetUpSuite disables the snappy autopilot. It will run before all the
// integration suites.
func (s *SnappySuite) SetUpSuite(c *check.C) {
	var err error
	Cfg, err = config.ReadConfig(
		"integration-tests/data/output/testconfig.json")
	c.Assert(err, check.IsNil, check.Commentf("Error reading config: %v", err))

	if !IsInRebootProcess() {
		if Cfg.Update || Cfg.Rollback {
			switchSystemImageConf(c, Cfg.TargetRelease, Cfg.TargetChannel, "0")
			// Always use the installed snappy because we are updating from an old
			// image, so we should not use the snappy from the branch.
			output := cli.ExecCommand(c, "sudo", "/usr/bin/snappy", "update")
			if output != "" {
				RebootWithMark(c, "setupsuite-update")
			}
		}
	} else if CheckRebootMark("setupsuite-update") {
		RemoveRebootMark(c)
		// Update was already executed. Update the config so it's not triggered again.
		Cfg.Update = false
		Cfg.Write()
		if Cfg.Rollback {
			cli.ExecCommand(c, "sudo", "snappy", "rollback", "ubuntu-core")
			RebootWithMark(c, "setupsuite-rollback")
		}
	} else if CheckRebootMark("setupsuite-rollback") {
		RemoveRebootMark(c)
		// Rollback was already executed. Update the config so it's not triggered again.
		Cfg.Rollback = false
		Cfg.Write()
	}
}
开发者ID:General-Beck,项目名称:snappy,代码行数:34,代码来源:common.go

示例6: init

func init() {
	c := &check.C{}
	// Workaround for bug https://bugs.launchpad.net/snappy/+bug/1498293
	// TODO remove once the bug is fixed
	// originally added by elopio - 2015-09-30 to the rollback test, moved
	// here by --fgimenez - 2015-10-15
	wait.ForFunction(c, "regular", partition.Mode)

	cli.ExecCommand(c, "sudo", "systemctl", "stop", "snappy-autopilot.timer")
	cli.ExecCommand(c, "sudo", "systemctl", "disable", "snappy-autopilot.timer")
}
开发者ID:robert-ancell,项目名称:snapd,代码行数:11,代码来源:base_test.go

示例7: TestAppUpdate

func (s *updateAppSuite) TestAppUpdate(c *check.C) {
	snap := "hello-world.canonical"
	storeSnap := fmt.Sprintf("%s/edge", snap)

	// install edge version from the store (which is squshfs)
	cli.ExecCommand(c, "sudo", "snappy", "install", storeSnap)
	defer cli.ExecCommand(c, "sudo", "snappy", "remove", snap)

	output := updates.CallFakeUpdate(c, snap, updates.NoOp)
	c.Assert(output, check.Matches, "(?ms).*^hello-world.*fake1.*")
}
开发者ID:robert-ancell,项目名称:snapd,代码行数:11,代码来源:update_app_test.go

示例8: TestActivateBringsBinaryBack

func (s *activateSuite) TestActivateBringsBinaryBack(c *check.C) {
	cli.ExecCommand(c, "sudo", "snappy", "deactivate", activateSnapName)
	cli.ExecCommand(c, "sudo", "snappy", "activate", activateSnapName)
	output := cli.ExecCommand(c, activateBinName)

	c.Assert(output, check.Equals, activateEchoOutput,
		check.Commentf("Wrong output from active snap binary"))

	list := cli.ExecCommand(c, "snappy", "list", "-v")

	c.Assert(list, check.Matches, activatedPattern)
}
开发者ID:robert-ancell,项目名称:snapd,代码行数:12,代码来源:activate_test.go

示例9: CallFakeSnapRefresh

// CallFakeSnapRefresh calls snappy update after faking a new version available for the specified snap.
// The fake is made copying the currently installed snap.
// changeFunc can be used to modify the snap before it is built and served.
func CallFakeSnapRefresh(c *check.C, snap string, changeFunc ChangeFakeUpdateSnap, fakeStore *store.Store) string {
	c.Log("Preparing fake and calling update.")

	blobDir := fakeStore.SnapsDir()
	makeFakeUpdateForSnap(c, snap, blobDir, changeFunc)

	// FIMXE: there is no "snap refresh" that updates all snaps
	cli.ExecCommand(c, "sudo", "TMPDIR=/var/tmp", "snap", "refresh", snap)

	// FIXME: do we want an automatic `snap list` output after
	//        `snap update` (like in the old snappy world)?
	return cli.ExecCommand(c, "snap", "list")
}
开发者ID:dholbach,项目名称:snappy,代码行数:16,代码来源:updates.go

示例10: TestDeactivateRemovesBinary

func (s *activateSuite) TestDeactivateRemovesBinary(c *check.C) {
	cli.ExecCommand(c, "sudo", "snappy", "deactivate", activateSnapName)
	defer cli.ExecCommand(c, "sudo", "snappy", "activate", activateSnapName)
	output, err := cli.ExecCommandErr(activateBinName)

	c.Assert(err, check.NotNil, check.Commentf("Deactivated snap binary did not exit with an error"))
	c.Assert(output, check.Not(check.Equals), activateEchoOutput,
		check.Commentf("Deactivated snap binary was not removed"))

	list := cli.ExecCommand(c, "snappy", "list", "-v")

	c.Assert(list, check.Matches, deActivatedPattern)
}
开发者ID:robert-ancell,项目名称:snapd,代码行数:13,代码来源:activate_test.go

示例11: TestInstallFromStoreMetadata

func (s *installAppSuite) TestInstallFromStoreMetadata(c *check.C) {
	common.InstallSnap(c, "hello-world/edge")
	defer common.RemoveSnap(c, "hello-world")

	output := cli.ExecCommand(c, "snappy", "info", "hello-world")
	c.Check(string(output), check.Matches, "(?ms)^channel: edge")
}
开发者ID:alecu,项目名称:snappy,代码行数:7,代码来源:installApp_test.go

示例12: renameFile

func renameFile(c *check.C, basePath, oldFilename, newFilename string, keepOld bool) {
	// Only need to make writable and revert for BaseAltPartitionPath,
	// kernel files' boot directory is writable
	if basePath == common.BaseAltPartitionPath {
		partition.MakeWritable(c, basePath)
		defer partition.MakeReadonly(c, basePath)
	}

	cli.ExecCommand(c, "sudo", "mv", oldFilename, newFilename)

	if keepOld {
		cli.ExecCommand(c, "sudo", "touch", oldFilename)
		mode := getFileMode(c, newFilename)
		cli.ExecCommand(c, "sudo", "chmod", fmt.Sprintf("%o", mode), oldFilename)
	}
}
开发者ID:General-Beck,项目名称:snappy,代码行数:16,代码来源:failover_zero_size_file_test.go

示例13: unInstallService

func unInstallService(c *check.C, serviceName, basePath string) {
	partition.MakeWritable(c, basePath)
	defer partition.MakeReadonly(c, basePath)

	// Disable the service
	cli.ExecCommand(c, "sudo", "chroot", basePath,
		"systemctl", "disable", fmt.Sprintf("%s.service", serviceName))

	// Remove the service file
	cli.ExecCommand(c, "sudo", "rm",
		fmt.Sprintf("%s%s/%s.service", basePath, baseSystemdPath, serviceName))

	// Remove the requires symlink
	cli.ExecCommand(c, "sudo", "rm",
		fmt.Sprintf("%s%s/%s/%s.service", basePath, baseSystemdPath, systemdTargetRequiresDir, serviceName))
}
开发者ID:General-Beck,项目名称:snappy,代码行数:16,代码来源:failover_systemd_loop_test.go

示例14: SetUpTest

func (s *initRAMFSSuite) SetUpTest(c *check.C) {
	s.SnappySuite.SetUpTest(c)
	if common.BeforeReboot() {
		bootDir := getCurrentBootDir(c)
		cli.ExecCommand(c, "cp", path.Join(bootDir, "initrd.img"), os.Getenv("ADT_ARTIFACTS"))
	}
}
开发者ID:sergiusens,项目名称:snappy-github-plugin,代码行数:7,代码来源:initramfs_test.go

示例15: installService

func installService(c *check.C, serviceName, serviceCfg, servicesPath string) {
	// Create service file.
	cli.ExecCommand(c, "sudo", "chmod", "a+w", servicesPath)
	serviceFileName := fmt.Sprintf("%s.service", serviceName)
	serviceFilePath := filepath.Join(servicesPath, serviceFileName)
	cli.ExecCommandToFile(c, serviceFilePath, "sudo", "echo", serviceCfg)

	// Create requires directory.
	requiresDir := filepath.Join(servicesPath, systemdTargetRequiresDir)
	cli.ExecCommand(c, "sudo", "mkdir", "-p", requiresDir)

	// Symlink from the requires dir to the service file.
	cli.ExecCommand(c, "sudo", "ln", "-s", serviceFilePath,
		filepath.Join(requiresDir, serviceFileName),
	)
}
开发者ID:robert-ancell,项目名称:snapd,代码行数:16,代码来源:failover_systemd_loop_test.go


注:本文中的github.com/ubuntu-core/snappy/integration-tests/testutils/cli.ExecCommand函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。