github.com/kubiko/snapd@v0.0.0-20201013125620-d4f3094d9ddf/arch/arch_test.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 3 /* 4 * Copyright (C) 2014-2015 Canonical Ltd 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 3 as 8 * published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 package arch 21 22 import ( 23 "testing" 24 25 . "gopkg.in/check.v1" 26 ) 27 28 // Hook up check.v1 into the "go test" runner 29 func Test(t *testing.T) { TestingT(t) } 30 31 var _ = Suite(&ArchTestSuite{}) 32 33 type ArchTestSuite struct { 34 } 35 36 func (ts *ArchTestSuite) TestArchDpkgArchitecture(c *C) { 37 c.Check(dpkgArchFromGoArch("386"), Equals, "i386") 38 c.Check(dpkgArchFromGoArch("amd64"), Equals, "amd64") 39 c.Check(dpkgArchFromGoArch("arm"), Equals, "armhf") 40 c.Check(dpkgArchFromGoArch("arm64"), Equals, "arm64") 41 c.Check(dpkgArchFromGoArch("ppc"), Equals, "powerpc") 42 c.Check(dpkgArchFromGoArch("ppc64"), Equals, "ppc64") 43 c.Check(dpkgArchFromGoArch("ppc64le"), Equals, "ppc64el") 44 c.Check(dpkgArchFromGoArch("riscv64"), Equals, "riscv64") 45 c.Check(dpkgArchFromGoArch("s390x"), Equals, "s390x") 46 } 47 48 func (ts *ArchTestSuite) TestArchSetArchitecture(c *C) { 49 SetArchitecture("armhf") 50 c.Assert(DpkgArchitecture(), Equals, "armhf") 51 } 52 53 func (ts *ArchTestSuite) TestArchSupportedArchitectures(c *C) { 54 arch = "armhf" 55 c.Check(IsSupportedArchitecture([]string{"all"}), Equals, true) 56 c.Check(IsSupportedArchitecture([]string{"amd64", "armhf", "powerpc"}), Equals, true) 57 c.Check(IsSupportedArchitecture([]string{"armhf"}), Equals, true) 58 c.Check(IsSupportedArchitecture([]string{"amd64", "powerpc"}), Equals, false) 59 60 arch = "amd64" 61 c.Check(IsSupportedArchitecture([]string{"all"}), Equals, true) 62 c.Check(IsSupportedArchitecture([]string{"amd64", "armhf", "powerpc"}), Equals, true) 63 c.Check(IsSupportedArchitecture([]string{"powerpc"}), Equals, false) 64 }