• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang cli.ExecCommand函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: TestListMustPrintCoreVersion

func (s *listSuite) TestListMustPrintCoreVersion(c *check.C) {
	listOutput := cli.ExecCommand(c, "snappy", "list")

	expected := "(?ms)" +
		"Name +Date +Version +Developer *\n" +
		".*" +
		fmt.Sprintf("^ubuntu-core +.* +%s +ubuntu *\n", getVersionFromConfig(c)) +
		".*"
	c.Assert(listOutput, check.Matches, expected)
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:10,代码来源:list_test.go


示例17: TestSearchFrameworkMustPrintMatch

func (s *searchSuite) TestSearchFrameworkMustPrintMatch(c *check.C) {
	searchOutput := cli.ExecCommand(c, "snappy", "search", "hello-dbus-fwk")

	expected := "(?ms)" +
		"Name +Version +Summary *\n" +
		".*" +
		"^hello-dbus-fwk +.* +hello-dbus-fwk *\n" +
		".*"

	c.Assert(searchOutput, check.Matches, expected)
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:11,代码来源:search_test.go


示例18: TestCallHelloWorldBinary

func (s *helloWorldExampleSuite) TestCallHelloWorldBinary(c *check.C) {
	common.InstallSnap(c, "hello-world")
	s.AddCleanup(func() {
		common.RemoveSnap(c, "hello-world")
	})

	echoOutput := cli.ExecCommand(c, "hello-world.echo")

	c.Assert(echoOutput, check.Equals, "Hello World!\n",
		check.Commentf("Wrong output from hello-world binary"))
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:11,代码来源:examples_test.go


示例19: GetCurrentVersion

// GetCurrentVersion returns the version of the installed and active package.
func GetCurrentVersion(c *check.C, packageName string) string {
	output := cli.ExecCommand(c, "snappy", "list")
	pattern := "(?mU)^" + packageName + " +(.*)$"
	re := regexp.MustCompile(pattern)
	match := re.FindStringSubmatch(string(output))
	c.Assert(match, check.NotNil, check.Commentf("Version not found in %s", output))

	// match is like "ubuntu-core   2015-06-18 93        ubuntu"
	items := strings.Fields(match[0])
	return items[2]
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:12,代码来源:common.go


示例20: installService

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

	// Create service file
	serviceFile := fmt.Sprintf("%s%s/%s.service", basePath, baseSystemdPath, serviceName)
	cli.ExecCommand(c, "sudo", "chmod", "a+w", fmt.Sprintf("%s%s", basePath, baseSystemdPath))
	cli.ExecCommandToFile(c, serviceFile, "sudo", "echo", serviceCfg)

	// Create requires directory
	requiresDirPart := fmt.Sprintf("%s/%s", baseSystemdPath, systemdTargetRequiresDir)
	requiresDir := fmt.Sprintf("%s%s", basePath, requiresDirPart)
	cli.ExecCommand(c, "sudo", "mkdir", "-p", requiresDir)

	// Symlink from the requires dir to the service file (with chroot for being
	// usable in the other partition)
	cli.ExecCommand(c, "sudo", "chroot", basePath, "ln", "-s",
		fmt.Sprintf("%s/%s.service", baseSystemdPath, serviceName),
		fmt.Sprintf("%s/%s.service", requiresDirPart, serviceName),
	)
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:21,代码来源:failover_systemd_loop_test.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang arch.UbuntuArchitecture函数代码示例发布时间:2022-05-28
下一篇:
Golang typed.WriteBuffer类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap