github.com/rigado/snapd@v2.42.5-go-mod+incompatible/cmd/snap-seccomp/export_test.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  
     3  /*
     4   * Copyright (C) 2019 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 main
    21  
    22  var (
    23  	Compile           = compile
    24  	SeccompResolver   = seccompResolver
    25  	VersionInfo       = versionInfo
    26  	GoSeccompFeatures = goSeccompFeatures
    27  )
    28  
    29  func MockArchDpkgArchitecture(f func() string) (restore func()) {
    30  	realArchDpkgArchitecture := archDpkgArchitecture
    31  	archDpkgArchitecture = f
    32  	return func() {
    33  		archDpkgArchitecture = realArchDpkgArchitecture
    34  	}
    35  }
    36  
    37  func MockArchDpkgKernelArchitecture(f func() string) (restore func()) {
    38  	realArchDpkgKernelArchitecture := archDpkgKernelArchitecture
    39  	archDpkgKernelArchitecture = f
    40  	return func() {
    41  		archDpkgKernelArchitecture = realArchDpkgKernelArchitecture
    42  	}
    43  }
    44  
    45  func MockErrnoOnDenial(i int16) (retore func()) {
    46  	origErrnoOnDenial := errnoOnDenial
    47  	errnoOnDenial = i
    48  	return func() {
    49  		errnoOnDenial = origErrnoOnDenial
    50  	}
    51  }
    52  
    53  func MockSeccompSyscalls(syscalls []string) (resture func()) {
    54  	old := seccompSyscalls
    55  	seccompSyscalls = syscalls
    56  	return func() {
    57  		seccompSyscalls = old
    58  	}
    59  }