Files
snapd/arch/export_test.go
Michael Vogt 9c72433ef0 arch: add new arch.Endian() helper and use it in seccomp (#13028)
* arch: add new `arch.Endian()` helper and use it in seccomp

Go has no good way to get the native endianness of a system.
However for certain use-cases (like seccomp) this is quite
important. We already have a (hackish) `isBigEndian()` helper
in our code. However this will also be needed in snap-seccomp
for PR#13014 this will also be needed so moving the helper
to the `arch` package seems to be prudent.

* arch: fix usage of runtimeGOARCH

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>

---------

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
2023-07-31 09:44:11 +02:00

31 lines
875 B
Go

// -*- Mode: Go; indent-tabs-mode: t -*-
/*
* Copyright (C) 2023 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 arch
import (
"github.com/snapcore/snapd/testutil"
)
func MockRuntimeGOARCH(arch string) (restore func()) {
restore = testutil.Backup(&runtimeGOARCH)
runtimeGOARCH = arch
return restore
}