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

Golang dirs.SetRootDir函数代码示例

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

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



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

示例1: SetUpTest

func (s *kernelTestSuite) SetUpTest(c *C) {
	dirs.SetRootDir(c.MkDir())
	s.bootloader = newMockBootloader(c.MkDir())
	findBootloader = func() (partition.Bootloader, error) {
		return s.bootloader, nil
	}
}
开发者ID:dholbach,项目名称:snappy,代码行数:7,代码来源:kernel_os_test.go


示例2: SetUpTest

func (t *CreateTestSuite) SetUpTest(c *C) {
	t.BaseTest.SetUpTest(c)

	dirs.SetRootDir(c.MkDir())

	// mock the chroot handler
	origRunInChroot := runInChroot
	t.AddCleanup(func() { runInChroot = origRunInChroot })
	runInChroot = func(chroot string, cmd ...string) error {
		t.runInChroot = append(t.runInChroot, cmd)
		return nil
	}

	// create some content for the webserver
	r := makeMockLxdTarball(c)
	t.AddCleanup(func() { r.Close() })
	t.imageReader = r

	// ensure getgrnam is called
	getgrnamOrig := getgrnam
	getgrnam = func(name string) (osutil.Group, error) {
		t.getgrnamCalled = append(t.getgrnamCalled, name)
		return osutil.Group{}, nil
	}
	t.AddCleanup(func() { getgrnam = getgrnamOrig })
}
开发者ID:dholbach,项目名称:snappy,代码行数:26,代码来源:create_test.go


示例3: SetUpTest

func (s *SnapTestSuite) SetUpTest(c *C) {
	s.secbase = policy.SecBase
	s.tempdir = c.MkDir()
	dirs.SetRootDir(s.tempdir)

	policy.SecBase = filepath.Join(s.tempdir, "security")
	os.MkdirAll(dirs.SnapServicesDir, 0755)
	os.MkdirAll(dirs.SnapSeccompDir, 0755)
	os.MkdirAll(dirs.SnapSnapsDir, 0755)

	release.Override(release.Release{Flavor: "core", Series: "15.04"})

	// create a fake systemd environment
	os.MkdirAll(filepath.Join(dirs.SnapServicesDir, "multi-user.target.wants"), 0755)

	systemd.SystemctlCmd = func(cmd ...string) ([]byte, error) {
		return []byte("ActiveState=inactive\n"), nil
	}

	// fake udevadm
	runUdevAdm = func(args ...string) error {
		return nil
	}

	// do not attempt to hit the real store servers in the tests
	nowhereURI, _ := url.Parse("")
	s.storeCfg = &store.SnapUbuntuStoreConfig{
		SearchURI: nowhereURI,
		BulkURI:   nowhereURI,
	}
	storeConfig = s.storeCfg
}
开发者ID:dholbach,项目名称:snappy,代码行数:32,代码来源:snapp_test.go


示例4: SetUpTest

func (s *apiSuite) SetUpTest(c *check.C) {
	dirs.SetRootDir(c.MkDir())

	s.parts = nil
	s.err = nil
	s.vars = nil
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:7,代码来源:api_test.go


示例5: SetUpTest

func (s *FirstBootTestSuite) SetUpTest(c *C) {
	tempdir := c.MkDir()
	dirs.SetRootDir(tempdir)
	stampFile = filepath.Join(c.MkDir(), "stamp")

	// mock the world!
	makeMockSecurityEnv(c)
	runAppArmorParser = mockRunAppArmorParser
	systemd.SystemctlCmd = func(cmd ...string) ([]byte, error) {
		return []byte("ActiveState=inactive\n"), nil
	}

	err := os.MkdirAll(filepath.Join(tempdir, "etc", "systemd", "system", "multi-user.target.wants"), 0755)
	c.Assert(err, IsNil)

	configMyApp := make(SystemConfig)
	configMyApp["hostname"] = "myhostname"

	s.gadgetConfig = make(SystemConfig)
	s.gadgetConfig["myapp"] = configMyApp

	s.globs = globs
	globs = nil
	s.ethdir = ethdir
	ethdir = c.MkDir()
	s.ifup = ifup
	ifup = "/bin/true"
	getGadget = s.getGadget
	newPartMap = s.newPartMap

	s.m = nil
	s.e = nil
	s.partMap = nil
	s.partMapErr = nil
}
开发者ID:robert-ancell,项目名称:snapd,代码行数:35,代码来源:firstboot_test.go


示例6: TestUnloadRemovesCachedProfile

func (s *appArmorSuite) TestUnloadRemovesCachedProfile(c *C) {
	cmd := testutil.MockCommand(c, "apparmor_parser", "")
	defer cmd.Restore()

	dirs.SetRootDir(c.MkDir())
	defer dirs.SetRootDir("")
	err := os.MkdirAll(dirs.AppArmorCacheDir, 0755)
	c.Assert(err, IsNil)

	fname := filepath.Join(dirs.AppArmorCacheDir, "profile")
	ioutil.WriteFile(fname, []byte("blob"), 0600)
	err = apparmor.UnloadProfile("profile")
	c.Assert(err, IsNil)
	_, err = os.Stat(fname)
	c.Check(os.IsNotExist(err), Equals, true)
}
开发者ID:dholbach,项目名称:snappy,代码行数:16,代码来源:apparmor_test.go


示例7: SetUpTest

func (s *ServiceActorSuite) SetUpTest(c *C) {
	// force UTC timezone, for reproducible timestamps
	os.Setenv("TZ", "")

	dirs.SetRootDir(c.MkDir())
	// TODO: this mkdir hack is so enable doesn't fail; remove when enable is the same as the rest
	c.Assert(os.MkdirAll(filepath.Join(dirs.GlobalRootDir, "/etc/systemd/system/multi-user.target.wants"), 0755), IsNil)
	systemd.SystemctlCmd = s.myRun
	systemd.JournalctlCmd = s.myJctl
	_, err := makeInstalledMockSnap(dirs.GlobalRootDir, `name: hello-app
version: 1.09
services:
 - name: svc1
   start: bin/hello
`)
	c.Assert(err, IsNil)
	f, err := makeInstalledMockSnap(dirs.GlobalRootDir, `name: hello-app
version: 1.10
services:
 - name: svc1
   start: bin/hello
`)
	c.Assert(err, IsNil)
	c.Assert(makeSnapActive(f), IsNil)
	s.i = 0
	s.argses = nil
	s.errors = nil
	s.outs = nil
	s.j = 0
	s.jsvcs = nil
	s.jouts = nil
	s.jerrs = nil
	s.pb = &MockProgressMeter{}
}
开发者ID:robert-ancell,项目名称:snapd,代码行数:34,代码来源:service_test.go


示例8: TearDownTest

func (s *interfaceManagerSuite) TearDownTest(c *C) {
	if s.privateMgr != nil {
		s.privateMgr.Stop()
	}
	dirs.SetRootDir("")
	s.restoreBackends()
}
开发者ID:dholbach,项目名称:snappy,代码行数:7,代码来源:ifacemgr_test.go


示例9: SetUpTest

func (s *PartitionTestSuite) SetUpTest(c *C) {
	dirs.SetRootDir(c.MkDir())
	err := os.MkdirAll((&grub{}).Dir(), 0755)
	c.Assert(err, IsNil)
	err = os.MkdirAll((&uboot{}).Dir(), 0755)
	c.Assert(err, IsNil)
}
开发者ID:robert-ancell,项目名称:snapd,代码行数:7,代码来源:bootloader_test.go


示例10: SetUpTest

func (s *SnapfsTestSuite) SetUpTest(c *C) {
	// mocks
	aaClickHookCmd = "/bin/true"
	dirs.SetRootDir(c.MkDir())

	// ensure we use the right builder func (snapfs)
	snapBuilderFunc = BuildSnapfsSnap
}
开发者ID:sergiusens,项目名称:snappy,代码行数:8,代码来源:snapp_snapfs_test.go


示例11: SetUpTest

func (s *apiSuite) SetUpTest(c *check.C) {
	dirs.SetRootDir(c.MkDir())
	c.Assert(os.MkdirAll(filepath.Dir(dirs.SnapLockFile), 0755), check.IsNil)

	s.parts = nil
	s.err = nil
	s.vars = nil
}
开发者ID:General-Beck,项目名称:snappy,代码行数:8,代码来源:api_test.go


示例12: TestFindServicesNoPackagesNoPattern

func (s *ServiceActorSuite) TestFindServicesNoPackagesNoPattern(c *C) {
	// tricky way of hiding the installed package ;)
	dirs.SetRootDir(c.MkDir())
	actor, err := FindServices("", "", s.pb)
	c.Check(err, IsNil)
	c.Assert(actor, NotNil)
	c.Check(actor.(*serviceActor).svcs, HasLen, 0)
}
开发者ID:robert-ancell,项目名称:snapd,代码行数:8,代码来源:service_test.go


示例13: SetUpTest

func (s *interfaceManagerSuite) SetUpTest(c *C) {
	dirs.SetRootDir(c.MkDir())
	state := state.New(nil)
	s.state = state
	s.privateMgr = nil
	s.extraIfaces = nil
	s.secBackend = &interfaces.TestSecurityBackend{}
	s.restoreBackends = ifacestate.MockSecurityBackends([]interfaces.SecurityBackend{s.secBackend})
}
开发者ID:dholbach,项目名称:snappy,代码行数:9,代码来源:ifacemgr_test.go


示例14: SetUpTest

func (s *undoTestSuite) SetUpTest(c *C) {
	dirs.SetRootDir(c.MkDir())
	err := os.MkdirAll(filepath.Join(dirs.GlobalRootDir, "etc", "systemd", "system", "multi-user.target.wants"), 0755)
	c.Assert(err, IsNil)

	systemd.SystemctlCmd = func(cmd ...string) ([]byte, error) {
		return []byte("ActiveState=inactive\n"), nil
	}
}
开发者ID:dholbach,项目名称:snappy,代码行数:9,代码来源:undo_test.go


示例15: SetUpTest

func (cs *clientSuite) SetUpTest(c *check.C) {
	cs.cli = client.New(nil)
	cs.cli.SetDoer(cs)
	cs.err = nil
	cs.rsp = ""
	cs.req = nil
	cs.header = nil
	cs.status = http.StatusOK

	dirs.SetRootDir(c.MkDir())
}
开发者ID:dholbach,项目名称:snappy,代码行数:11,代码来源:client_test.go


示例16: init

func init() {
	// init the global directories at startup
	root := os.Getenv("SNAPPY_GLOBAL_ROOT")
	if root == "" {
		root = "/"
	}

	dirs.SetRootDir(root)

	// we don't need to care for the error here to take into account when
	// initialized on a non snappy system
	release.Setup(dirs.GlobalRootDir)
}
开发者ID:General-Beck,项目名称:snappy,代码行数:13,代码来源:globals.go


示例17: SetUpTest

func (s *BuildTestSuite) SetUpTest(c *C) {
	s.BaseTest.SetUpTest(c)

	// chdir into a tempdir
	pwd, err := os.Getwd()
	c.Assert(err, IsNil)
	s.AddCleanup(func() { os.Chdir(pwd) })
	err = os.Chdir(c.MkDir())
	c.Assert(err, IsNil)

	// use fake root
	dirs.SetRootDir(c.MkDir())
}
开发者ID:dholbach,项目名称:snappy,代码行数:13,代码来源:build_test.go


示例18: SetUpTest

func (s *backendSuite) SetUpTest(c *C) {
	// Isolate this test to a temporary directory
	s.rootDir = c.MkDir()
	dirs.SetRootDir(s.rootDir)
	// Prepare a directory for DBus configuration files.
	// NOTE: Normally this is a part of the OS snap.
	err := os.MkdirAll(dirs.SnapBusPolicyDir, 0700)
	c.Assert(err, IsNil)
	// Create a fresh repository for each test
	s.repo = interfaces.NewRepository()
	s.iface = &interfaces.TestInterface{InterfaceName: "iface"}
	err = s.repo.AddInterface(s.iface)
	c.Assert(err, IsNil)
}
开发者ID:dholbach,项目名称:snappy,代码行数:14,代码来源:backend_test.go


示例19: SetUpTest

func (s *SnapTestSuite) SetUpTest(c *C) {
	s.secbase = policy.SecBase
	s.tempdir = c.MkDir()
	newPartition = func() (p partition.Interface) {
		return new(MockPartition)
	}

	dirs.SetRootDir(s.tempdir)
	policy.SecBase = filepath.Join(s.tempdir, "security")
	os.MkdirAll(dirs.SnapServicesDir, 0755)
	os.MkdirAll(dirs.SnapSeccompDir, 0755)

	release.Override(release.Release{Flavor: "core", Series: "15.04"})

	dirs.ClickSystemHooksDir = filepath.Join(s.tempdir, "/usr/share/click/hooks")
	os.MkdirAll(dirs.ClickSystemHooksDir, 0755)

	// create a fake systemd environment
	os.MkdirAll(filepath.Join(dirs.SnapServicesDir, "multi-user.target.wants"), 0755)

	// we may not have debsig-verify installed (and we don't need it
	// for the unittests)
	clickdeb.VerifyCmd = "true"
	systemd.SystemctlCmd = func(cmd ...string) ([]byte, error) {
		return []byte("ActiveState=inactive\n"), nil
	}

	// fake "du"
	duCmd = makeFakeDuCommand(c)

	// fake udevadm
	runUdevAdm = func(args ...string) error {
		return nil
	}

	// do not attempt to hit the real store servers in the tests
	storeSearchURI, _ = url.Parse("")
	storeDetailsURI, _ = url.Parse("")
	storeBulkURI, _ = url.Parse("")

	aaExec = filepath.Join(s.tempdir, "aa-exec")
	err := ioutil.WriteFile(aaExec, []byte(mockAaExecScript), 0755)
	c.Assert(err, IsNil)

	runAppArmorParser = mockRunAppArmorParser

	makeMockSecurityEnv(c)
}
开发者ID:General-Beck,项目名称:snappy,代码行数:48,代码来源:snapp_test.go


示例20: SetUpTest

func (s *purgeSuite) SetUpTest(c *C) {
	s.tempdir = c.MkDir()
	dirs.SetRootDir(s.tempdir)
	os.MkdirAll(dirs.SnapMetaDir, 0755)
	os.MkdirAll(filepath.Join(dirs.SnapServicesDir, "multi-user.target.wants"), 0755)
	systemd.SystemctlCmd = func(cmd ...string) ([]byte, error) {
		return []byte("ActiveState=inactive\n"), nil
	}

	dirs.SnapSeccompDir = c.MkDir()
	dirs.SnapAppArmorDir = c.MkDir()

	runAppArmorParser = mockRunAppArmorParser

	makeMockSecurityEnv(c)
}
开发者ID:alecu,项目名称:snappy,代码行数:16,代码来源:purge_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang helpers.AtomicWriteFile函数代码示例发布时间:2022-05-28
下一篇:
Golang asserts.OpenPGPPrivateKey函数代码示例发布时间: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