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


Golang C.Log方法代码示例

本文整理汇总了Golang中launchpad/net/gocheck.C.Log方法的典型用法代码示例。如果您正苦于以下问题:Golang C.Log方法的具体用法?Golang C.Log怎么用?Golang C.Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在launchpad/net/gocheck.C的用法示例。


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

示例1: TestArgs

func (s *JujuCMainSuite) TestArgs(c *gc.C) {
	for _, t := range argsTests {
		c.Log(t.args)
		output := run(c, s.sockPath, "bill", t.code, t.args...)
		c.Assert(output, gc.Equals, t.output)
	}
}
开发者ID:zhouqt,项目名称:juju,代码行数:7,代码来源:main_test.go

示例2: TestSimpleInstallAndStartImage

func (s *IntegrationTestSuite) TestSimpleInstallAndStartImage(c *chk.C) {
	id, err := containers.NewIdentifier("IntTest000")
	c.Assert(err, chk.IsNil)
	s.containerIds = append(s.containerIds, id)

	hostContainerId := fmt.Sprintf("%v/%v", s.daemonURI, id)

	cmd := exec.Command("/usr/bin/gear", "install", TestImage, hostContainerId)
	data, err := cmd.CombinedOutput()
	c.Log(string(data))
	c.Assert(err, chk.IsNil)
	s.assertContainerState(c, id, CONTAINER_STOPPED)

	s.assertFilePresent(c, id.UnitPathFor(), 0664, true)
	paths, err := filepath.Glob(id.VersionedUnitPathFor("*"))
	c.Assert(err, chk.IsNil)
	for _, p := range paths {
		s.assertFilePresent(c, p, 0664, true)
	}
	s.assertFileAbsent(c, filepath.Join(id.HomePath(), "container-init.sh"))

	ports, err := containers.GetExistingPorts(id)
	c.Assert(err, chk.IsNil)
	c.Assert(len(ports), chk.Equals, 0)

	cmd = exec.Command("/usr/bin/gear", "status", hostContainerId)
	data, err = cmd.CombinedOutput()
	c.Assert(err, chk.IsNil)
	c.Log(string(data))
	c.Assert(strings.Contains(string(data), "Loaded: loaded (/var/lib/containers/units/In/ctr-IntTest000.service; enabled)"), chk.Equals, true)
	s.assertContainerState(c, id, CONTAINER_STOPPED)
}
开发者ID:roacobb,项目名称:geard,代码行数:32,代码来源:integration_test.go

示例3: TestWeightedTimeSeeded

func (s *S) TestWeightedTimeSeeded(c *check.C) {
	c.Log("Note: This test is stochastic and is expected to fail with probability ≈ 0.05.")
	rand.Seed(time.Now().Unix())
	f := make([]float64, len(sel))
	ts := make(Selector, len(sel))

	for i := 0; i < 1e6; i++ {
		copy(ts, sel)
		ts.Init()
		item, err := ts.Select()
		if err != nil {
			c.Fatal(err)
		}
		f[item-1]++
	}

	fsum, exsum := 0., 0.
	for i := range f {
		fsum += f[i]
		exsum += exp[i]
	}
	fac := fsum / exsum
	for i := range f {
		exp[i] *= fac
	}

	// Check that our obtained values are within statistical expectations for p = 0.05.
	// This will not be true approximately 1 in 20 tests.
	X := chi2(f, exp)
	c.Logf("H₀: d(Sample) = d(Expect), H₁: d(S) ≠ d(Expect). df = %d, p = 0.05, X² threshold = %.2f, X² = %f", len(f)-1, sigChi2, X)
	c.Check(X < sigChi2, check.Equals, true)
}
开发者ID:kortschak,项目名称:graph,代码行数:32,代码来源:weighted_test.go

示例4: TestMergeIds

func (s *ActionSuite) TestMergeIds(c *gc.C) {
	var tests = []struct {
		initial  string
		changes  string
		adds     string
		removes  string
		expected string
	}{
		{initial: "", changes: "", adds: "a0,a1", removes: "", expected: "a0,a1"},
		{initial: "", changes: "a0,a1", adds: "", removes: "a0", expected: "a1"},
		{initial: "", changes: "a0,a1", adds: "a2", removes: "a0", expected: "a1,a2"},

		{initial: "a0", changes: "", adds: "a0,a1,a2", removes: "a0,a2", expected: "a1"},
		{initial: "a0", changes: "", adds: "a0,a1,a2", removes: "a0,a1,a2", expected: ""},

		{initial: "a0", changes: "a0", adds: "a0,a1,a2", removes: "a0,a2", expected: "a1"},
		{initial: "a0", changes: "a1", adds: "a0,a1,a2", removes: "a0,a2", expected: "a1"},
		{initial: "a0", changes: "a2", adds: "a0,a1,a2", removes: "a0,a2", expected: "a1"},

		{initial: "a0,a1,a2", changes: "a3,a4", adds: "a1,a4,a5", removes: "a1,a3", expected: "a4,a5"},
		{initial: "a0,a1,a2", changes: "a0,a1,a2", adds: "a1,a4,a5", removes: "a1,a3", expected: "a0,a2,a4,a5"},
	}

	for ix, test := range tests {
		updates := mapify(test.adds, test.removes)
		changes := newSet(test.changes)
		initial := newSet(test.initial)
		expected := newSet(test.expected)

		c.Log(fmt.Sprintf("test number %d %+v", ix, test))
		err := state.WatcherMergeIds(changes, initial, updates)
		c.Assert(err, gc.IsNil)
		c.Assert(changes.SortedValues(), jc.DeepEquals, expected.SortedValues())
	}
}
开发者ID:kapilt,项目名称:juju,代码行数:35,代码来源:action_test.go

示例5: SetUpTest

func (b *buildSuite) SetUpTest(c *gc.C) {
	b.BaseSuite.SetUpTest(c)

	dir1 := c.MkDir()
	dir2 := c.MkDir()

	c.Log(dir1)
	c.Log(dir2)

	path := os.Getenv("PATH")
	os.Setenv("PATH", fmt.Sprintf("%s:%s:%s", dir1, dir2, path))

	// Make an executable file called "juju-test" in dir2.
	b.filePath = filepath.Join(dir2, "juju-test")
	err := ioutil.WriteFile(
		b.filePath,
		[]byte("doesn't matter, we don't execute it"),
		0755)
	c.Assert(err, gc.IsNil)

	cwd, err := os.Getwd()
	c.Assert(err, gc.IsNil)

	b.cwd = c.MkDir()
	err = os.Chdir(b.cwd)
	c.Assert(err, gc.IsNil)

	b.restore = func() {
		os.Setenv("PATH", path)
		os.Chdir(cwd)
	}
}
开发者ID:jkary,项目名称:core,代码行数:32,代码来源:build_test.go

示例6: TestRestartContainer

func (s *IntegrationTestSuite) TestRestartContainer(c *chk.C) {
	id, err := containers.NewIdentifier("IntTest004")
	c.Assert(err, chk.IsNil)
	s.containerIds = append(s.containerIds, id)

	hostContainerId := fmt.Sprintf("%v/%v", s.daemonURI, id)

	cmd := exec.Command("/usr/bin/gear", "install", TestImage, hostContainerId, "--ports=8080:4002", "--start", "--isolate")
	data, err := cmd.CombinedOutput()
	c.Log(string(data))
	c.Assert(err, chk.IsNil)
	s.assertFilePresent(c, id.UnitPathFor(), 0664, true)
	s.assertContainerState(c, id, CONTAINER_STARTED)
	s.assertFilePresent(c, filepath.Join(id.HomePath(), "container-init.sh"), 0700, false)
	oldPid := s.getContainerPid(id)

	cmd = exec.Command("/usr/bin/gear", "restart", hostContainerId)
	data, err = cmd.CombinedOutput()
	c.Log(string(data))
	c.Assert(err, chk.IsNil)
	s.assertContainerState(c, id, CONTAINER_RESTARTED)

	newPid := s.getContainerPid(id)
	c.Assert(oldPid, chk.Not(chk.Equals), newPid)
}
开发者ID:roacobb,项目名称:geard,代码行数:25,代码来源:integration_test.go

示例7: TestSyncing

func (s *syncSuite) TestSyncing(c *gc.C) {
	for _, test := range tests {
		// Perform all tests in a "clean" environment.
		func() {
			s.setUpTest(c)
			defer s.tearDownTest(c)

			c.Log(test.description)

			if test.source {
				test.ctx.Source = s.localStorage
			}

			err := sync.SyncTools(test.ctx)
			c.Assert(err, gc.IsNil)

			targetTools, err := environs.FindAvailableTools(s.targetEnv, 1)
			c.Assert(err, gc.IsNil)
			assertToolsList(c, targetTools, test.tools)

			if test.emptyPublic {
				assertEmpty(c, s.targetEnv.PublicStorage())
			} else {
				assertEmpty(c, s.targetEnv.Storage())
			}
		}()
	}
}
开发者ID:hivetech,项目名称:judo.legacy,代码行数:28,代码来源:sync_test.go

示例8: TestIsValidArch

func (*InstanceTypeSuite) TestIsValidArch(c *gc.C) {
	types := preferredTypes{}

	// No architecture needs to be specified.
	c.Check(types.isValidArch(nil), gc.Equals, true)

	// Azure supports these architectures...
	supported := []string{
		"amd64",
		"i386",
	}
	for _, arch := range supported {
		c.Log("Checking that %q is supported.", arch)
		c.Check(types.isValidArch(&arch), gc.Equals, true)
	}

	// ...But not these.
	unsupported := []string{
		"",
		"axp",
		"powerpc",
	}
	for _, arch := range unsupported {
		c.Log("Checking that %q is not supported.", arch)
		c.Check(types.isValidArch(&arch), gc.Equals, false)
	}
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:27,代码来源:instancetype_test.go

示例9: TestString

func (*ArgsSuite) TestString(c *gc.C) {
	for i, test := range []struct {
		message  string
		target   []string
		expected string
	}{{
		message:  "null",
		expected: "",
	}, {
		message:  "empty",
		target:   []string{},
		expected: "",
	}, {
		message:  "single value",
		target:   []string{"foo"},
		expected: "foo",
	}, {
		message:  "multiple values",
		target:   []string{"foo", "bar", "baz"},
		expected: "foo,bar,baz",
	}} {
		c.Log(fmt.Sprintf("%v: %s", i, test.message))
		var temp []string
		value := cmd.NewStringsValue(test.target, &temp)
		c.Assert(value.String(), gc.Equals, test.expected)
	}
}
开发者ID:rogpeppe,项目名称:juju-cmd,代码行数:27,代码来源:args_test.go

示例10: TestLongContainerName

func (s *IntegrationTestSuite) TestLongContainerName(c *chk.C) {
	id, err := containers.NewIdentifier("IntTest006xxxxxxxxxxxxxx")
	c.Assert(err, chk.IsNil)
	s.containerIds = append(s.containerIds, id)

	hostContainerId := fmt.Sprintf("%v/%v", s.daemonURI, id)

	cmd := exec.Command("/usr/bin/gear", "install", TestImage, hostContainerId, "--start", "--ports=8080:0", "--isolate")
	data, err := cmd.CombinedOutput()
	c.Log(string(data))
	c.Assert(err, chk.IsNil)
	s.assertContainerStarts(c, id)

	s.assertFilePresent(c, id.UnitPathFor(), 0664, true)
	s.assertFilePresent(c, filepath.Join(id.RunPathFor(), "container-init.sh"), 0700, false)

	ports, err := containers.GetExistingPorts(id)
	c.Assert(err, chk.IsNil)
	c.Assert(len(ports), chk.Equals, 1)

	httpAlive := func() bool {
		resp, err := http.Get(fmt.Sprintf("http://0.0.0.0:%v", ports[0].External))
		if err == nil {
			c.Assert(resp.StatusCode, chk.Equals, 200)
			return true
		}
		return false
	}
	if !until(TimeoutContainerStateChange, IntervalHttpCheck, httpAlive) {
		c.Errorf("Unable to retrieve a 200 status code from port %d", ports[0].External)
		c.FailNow()
	}
}
开发者ID:jhadvig,项目名称:geard,代码行数:33,代码来源:integration_test.go

示例11: TestLogAndGetTestLog

func (s *BootstrapS) TestLogAndGetTestLog(c *gocheck.C) {
	c.Log("Hello there!")
	log := c.GetTestLog()
	if log != "Hello there!\n" {
		critical(fmt.Sprintf("Log() or GetTestLog() is not working! Got: %#v", log))
	}
}
开发者ID:kelsieflynn,项目名称:gocheck,代码行数:7,代码来源:bootstrap_test.go

示例12: TestSamePortRejected

func (s *IntegrationTestSuite) TestSamePortRejected(c *chk.C) {
	id, err := containers.NewIdentifier("TestSamePortRejected")
	c.Assert(err, chk.IsNil)
	s.containerIds = append(s.containerIds, id)

	hostContainerId := fmt.Sprintf("%v/%v", s.daemonURI, id)

	cmd := exec.Command("/usr/bin/gear", "install", TestImage, hostContainerId, "--ports=8080:39485")
	data, err := cmd.CombinedOutput()
	c.Log(string(data))
	c.Assert(err, chk.IsNil)
	active, _ := s.unitState(id)
	c.Assert(active, chk.Equals, "inactive")

	s.assertFilePresent(c, id.UnitPathFor(), 0664, true)
	paths, err := filepath.Glob(id.VersionedUnitPathFor("*"))
	c.Assert(err, chk.IsNil)
	for _, p := range paths {
		s.assertFilePresent(c, p, 0664, true)
	}

	id2, _ := containers.NewIdentifier("TestSamePortRejected2")
	cmd = exec.Command("/usr/bin/gear", "install", TestImage, fmt.Sprintf("%v/%v", s.daemonURI, id2), "--ports=8080:39485")
	data, err = cmd.CombinedOutput()
	c.Log(string(data))
	c.Assert(err, chk.ErrorMatches, "exit status 1")
	state, substate := s.unitState(id2)
	c.Assert(state, chk.Equals, "inactive")
	c.Assert(substate, chk.Equals, "dead")
}
开发者ID:jcantrill,项目名称:geard,代码行数:30,代码来源:integration_test.go

示例13: TestFlagsUsage

func (*ArgsSuite) TestFlagsUsage(c *gc.C) {
	for i, test := range []struct {
		message       string
		defaultValue  []string
		args          []string
		expectedValue []string
	}{{
		message: "nil default and no arg",
	}, {
		message:       "default value and not set by args",
		defaultValue:  []string{"foo", "bar"},
		expectedValue: []string{"foo", "bar"},
	}, {
		message:       "no value set by args",
		args:          []string{"--value", "foo,bar"},
		expectedValue: []string{"foo", "bar"},
	}, {
		message:       "default value and set by args",
		defaultValue:  []string{"omg"},
		args:          []string{"--value", "foo,bar"},
		expectedValue: []string{"foo", "bar"},
	}} {
		c.Log(fmt.Sprintf("%v: %s", i, test.message))
		f := gnuflag.NewFlagSet("test", gnuflag.ContinueOnError)
		f.SetOutput(ioutil.Discard)
		var value []string
		f.Var(cmd.NewStringsValue(test.defaultValue, &value), "value", "help")
		err := f.Parse(false, test.args)
		c.Check(err, gc.IsNil)
		c.Check(value, gc.DeepEquals, test.expectedValue)
	}
}
开发者ID:rogpeppe,项目名称:juju-cmd,代码行数:32,代码来源:args_test.go

示例14: TestTimeoutArgParsing

func (*RunSuite) TestTimeoutArgParsing(c *gc.C) {
	for i, test := range []struct {
		message  string
		args     []string
		errMatch string
		timeout  time.Duration
	}{{
		message: "default time",
		args:    []string{"--all", "sudo reboot"},
		timeout: 5 * time.Minute,
	}, {
		message:  "invalid time",
		args:     []string{"--timeout=foo", "--all", "sudo reboot"},
		errMatch: `invalid value "foo" for flag --timeout: time: invalid duration foo`,
	}, {
		message: "two hours",
		args:    []string{"--timeout=2h", "--all", "sudo reboot"},
		timeout: 2 * time.Hour,
	}, {
		message: "3 minutes 30 seconds",
		args:    []string{"--timeout=3m30s", "--all", "sudo reboot"},
		timeout: (3 * time.Minute) + (30 * time.Second),
	}} {
		c.Log(fmt.Sprintf("%v: %s", i, test.message))
		runCmd := &RunCommand{}
		testing.TestInit(c, envcmd.Wrap(runCmd), test.args, test.errMatch)
		if test.errMatch == "" {
			c.Check(runCmd.timeout, gc.Equals, test.timeout)
		}
	}
}
开发者ID:jiasir,项目名称:juju,代码行数:31,代码来源:run_test.go

示例15: TestLongContainerName

func (s *IntegrationTestSuite) TestLongContainerName(c *chk.C) {
	id, err := containers.NewIdentifier("IntTest006xxxxxxxxxxxxxx")
	c.Assert(err, chk.IsNil)
	s.containerIds = append(s.containerIds, id)

	hostContainerId := fmt.Sprintf("%v/%v", s.daemonURI, id)

	cmd := exec.Command("/usr/bin/gear", "install", TestImage, hostContainerId, "--start", "--ports=8080:4003", "--isolate")
	data, err := cmd.CombinedOutput()
	c.Log(string(data))
	c.Assert(err, chk.IsNil)
	s.assertContainerState(c, id, CONTAINER_STARTED)

	s.assertFilePresent(c, id.UnitPathFor(), 0664, true)
	s.assertFilePresent(c, filepath.Join(id.HomePath(), "container-init.sh"), 0700, false)

	ports, err := containers.GetExistingPorts(id)
	c.Assert(err, chk.IsNil)
	c.Assert(len(ports), chk.Equals, 1)

	t := time.NewTicker(time.Second / 10)
	defer t.Stop()
	select {
	case <-t.C:
		resp, err := http.Get(fmt.Sprintf("http://0.0.0.0:%v", ports[0].External))
		if err == nil {
			c.Assert(resp.StatusCode, chk.Equals, 200)
		}
	case <-time.After(time.Second * 15):
		c.Fail()
	}
}
开发者ID:roacobb,项目名称:geard,代码行数:32,代码来源:integration_test.go


注:本文中的launchpad/net/gocheck.C.Log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。