代码拉取完成,页面将自动刷新
同步操作将从 tupelo-shen/mysnapd 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
// -*- Mode: Go; indent-tabs-mode: t -*-
/*
* Copyright (C) 2014-2018 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package osutil_test
import (
"bytes"
"errors"
"os/exec"
"syscall"
"gopkg.in/check.v1"
"gitee.com/mysnapcore/mysnapd/osutil"
)
type unameSuite struct{}
var _ = check.Suite(unameSuite{})
func ucmd1(c *check.C, arg string) string {
out, err := exec.Command("uname", arg).CombinedOutput()
c.Assert(err, check.IsNil)
return string(bytes.TrimSpace(out))
}
func (unameSuite) TestUname(c *check.C) {
c.Check(osutil.KernelVersion(), check.Equals, ucmd1(c, "-r"))
c.Check(osutil.MachineName(), check.Equals, ucmd1(c, "-m"))
}
func (unameSuite) TestUnameErrorMeansUnknown(c *check.C) {
restore := osutil.MockUname(func(buf *syscall.Utsname) error {
return errors.New("bzzzt")
})
defer restore()
c.Check(osutil.KernelVersion(), check.Equals, "unknown")
c.Check(osutil.MachineName(), check.Equals, "unknown")
}
func (unameSuite) TestKernelVersionStopsAtZeroes(c *check.C) {
restore := osutil.MockUname(func(buf *syscall.Utsname) error {
buf.Release[0] = 'f'
buf.Release[1] = 'o'
buf.Release[2] = 'o'
buf.Release[3] = 0
buf.Release[4] = 'u'
buf.Release[5] = 'n'
buf.Release[6] = 'u'
buf.Release[7] = 's'
buf.Release[8] = 'e'
buf.Release[9] = 'd'
return nil
})
defer restore()
c.Check(osutil.KernelVersion(), check.Equals, "foo")
}
func (unameSuite) TestMachineNameStopsAtZeroes(c *check.C) {
restore := osutil.MockUname(func(buf *syscall.Utsname) error {
buf.Machine[0] = 'a'
buf.Machine[1] = 'r'
buf.Machine[2] = 'm'
buf.Machine[3] = 'v'
buf.Machine[4] = '7'
buf.Machine[5] = 'a'
buf.Machine[6] = 0
buf.Machine[7] = 'u'
buf.Machine[8] = 'n'
buf.Machine[9] = 'u'
buf.Machine[10] = 's'
buf.Machine[11] = 'e'
buf.Machine[12] = 'd'
return nil
})
defer restore()
c.Check(osutil.MachineName(), check.Equals, "armv7a")
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。