当前位置: 首页>>代码示例>>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 {
			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:pombredanne,项目名称:snappy-1,代码行数:34,代码来源:common.go

示例2: 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:pombredanne,项目名称:snappy-1,代码行数:11,代码来源:base_test.go

示例3: 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:pombredanne,项目名称:snappy-1,代码行数:12,代码来源:activate_test.go

示例4: 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:pombredanne,项目名称:snappy-1,代码行数:13,代码来源:activate_test.go

示例5: replaceSystemImageValues

func replaceSystemImageValues(c *check.C, file, release, channel, version string) {
	c.Log("Switching the system image conf...")
	replaceRegex := map[string]string{
		release: `s#channel: ubuntu-core/.*/\(.*\)#channel: ubuntu-core/%s/\1#`,
		channel: `s#channel: ubuntu-core/\(.*\)/.*#channel: ubuntu-core/\1/%s#`,
		version: `s/build_number: .*/build_number: %s/`,
	}
	for value, regex := range replaceRegex {
		if value != "" {
			cli.ExecCommand(c,
				"sudo", "sed", "-i", fmt.Sprintf(regex, value), file)
		}
	}
	// Leave the new file in the test log.
	cli.ExecCommand(c, "cat", file)
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:16,代码来源:common.go

示例6: 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:pombredanne,项目名称:snappy-1,代码行数:16,代码来源:failover_systemd_loop_test.go

示例7: 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:pombredanne,项目名称:snappy-1,代码行数:16,代码来源:failover_zero_size_file_test.go

示例8: 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:pombredanne,项目名称:snappy-1,代码行数:7,代码来源:initramfs_test.go

示例9: TestFanCommandCreatesFanBridge

func (s *fanTestSuite) TestFanCommandCreatesFanBridge(c *check.C) {
	output := cli.ExecCommand(c, "ifconfig")

	expectedPattern := fmt.Sprintf("(?msi).*%s.*%s.*", s.fanName(), s.bridgeIP)

	c.Assert(output, check.Matches, expectedPattern,
		check.Commentf("Expected pattern %s not found in %s", expectedPattern, output))
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:8,代码来源:ubuntuFan_test.go

示例10: TearDownTest

func (s *initRAMFSSuite) TearDownTest(c *check.C) {
	s.SnappySuite.TearDownTest(c)
	if !common.IsInRebootProcess() {
		bootDir := getCurrentBootDir(c)
		cli.ExecCommand(
			c, "sudo", "mv", path.Join(os.Getenv("ADT_ARTIFACTS"), "initrd.img"), bootDir)
	}
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:8,代码来源:initramfs_test.go

示例11: set

func (rcLocalCrash) set(c *check.C) {
	partition.MakeWritable(c, common.BaseAltPartitionPath)
	defer partition.MakeReadonly(c, common.BaseAltPartitionPath)
	targetFile := fmt.Sprintf("%s/etc/rc.local", common.BaseAltPartitionPath)
	cli.ExecCommand(c, "sudo", "chmod", "a+xw", targetFile)

	cli.ExecCommandToFile(c, targetFile,
		"sudo", "echo", "#!bin/sh\nprintf c > /proc/sysrq-trigger")
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:9,代码来源:failover_rclocal_crash_test.go

示例12: configureDockerToUseBridge

func (s *fanTestSuite) configureDockerToUseBridge(c *check.C) {
	cfgFile := dockerCfgFile(c)

	cli.ExecCommand(c, "sudo", "sed", "-i",
		fmt.Sprintf(`s/DOCKER_OPTIONS=\"\"/DOCKER_OPTIONS=\"%s\"/`, s.dockerOptions()),
		cfgFile)

	restartDocker(c)
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:9,代码来源:ubuntuFan_test.go

示例13: removeBridgeFromDockerConf

func (s *fanTestSuite) removeBridgeFromDockerConf(c *check.C) {
	cfgFile := dockerCfgFile(c)

	cli.ExecCommand(c, "sudo", "sed", "-i",
		`s/DOCKER_OPTIONS=\".*\"/DOCKER_OPTIONS=\"\"/`,
		cfgFile)

	restartDocker(c)
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:9,代码来源:ubuntuFan_test.go

示例14: TestContainersInTheFanAreReachable

func (s *fanTestSuite) TestContainersInTheFanAreReachable(c *check.C) {
	setUpDocker(c)
	defer tearDownDocker(c)
	s.configureDockerToUseBridge(c)
	defer s.removeBridgeFromDockerConf(c)

	// spin up first container
	cli.ExecCommand(c, "docker", "run", "-d", "-t", baseContainer)
	// the first assigned IP in the fan will end with ".2"
	firstIPAddr := strings.TrimRight(s.bridgeIP, ".1") + ".2"

	// ping from a second container
	output := cli.ExecCommand(c, "docker", "run", "-t", baseContainer, "ping", firstIPAddr, "-c", "1")

	expectedPattern := "(?ms).*1 packets transmitted, 1 packets received, 0% packet loss.*"

	c.Assert(output, check.Matches, expectedPattern,
		check.Commentf("Expected pattern %s not found in %s", expectedPattern, output))
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:19,代码来源:ubuntuFan_test.go

示例15: TestCallSuccessfulBinaryFromInstalledSnap

func (s *installAppSuite) TestCallSuccessfulBinaryFromInstalledSnap(c *check.C) {
	snapPath, err := build.LocalSnap(c, data.BasicBinariesSnapName)
	defer os.Remove(snapPath)
	c.Assert(err, check.IsNil, check.Commentf("Error building local snap: %s", err))
	common.InstallSnap(c, snapPath)
	defer common.RemoveSnap(c, data.BasicBinariesSnapName)

	// Exec command does not fail.
	cli.ExecCommand(c, "basic-binaries.success")
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:10,代码来源:installApp_test.go


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