gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/runsc/fsgofer/lisafs_test.go (about)

     1  // Copyright 2021 The gVisor Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package lisafs_test
    16  
    17  import (
    18  	"testing"
    19  
    20  	"gvisor.dev/gvisor/pkg/lisafs"
    21  	"gvisor.dev/gvisor/pkg/lisafs/testsuite"
    22  	"gvisor.dev/gvisor/pkg/log"
    23  	"gvisor.dev/gvisor/runsc/fsgofer"
    24  )
    25  
    26  // Note that these are not supposed to be extensive or robust tests. These unit
    27  // tests provide a sanity check that all RPCs at least work in obvious ways.
    28  
    29  func init() {
    30  	log.SetLevel(log.Debug)
    31  	if err := fsgofer.OpenProcSelfFD("/proc/self/fd"); err != nil {
    32  		panic(err)
    33  	}
    34  }
    35  
    36  // tester implements testsuite.Tester.
    37  type tester struct{}
    38  
    39  // NewServer implements testsuite.Tester.NewServer.
    40  func (tester) NewServer(t *testing.T) *lisafs.Server {
    41  	return &fsgofer.NewLisafsServer(fsgofer.Config{}).Server
    42  }
    43  
    44  // LinkSupported implements testsuite.Tester.LinkSupported.
    45  func (tester) LinkSupported() bool {
    46  	return true
    47  }
    48  
    49  // SetUserGroupIDSupported implements testsuite.Tester.SetUserGroupIDSupported.
    50  func (tester) SetUserGroupIDSupported() bool {
    51  	return true
    52  }
    53  
    54  // BindSupported implements testsuite.Tester.BindSupported.
    55  func (tester) BindSupported() bool {
    56  	// In some test environments, the mount path is really large and bind(2)
    57  	// fails with EINVAL if the path length >= 108.
    58  	return false
    59  }
    60  
    61  func TestFSGofer(t *testing.T) {
    62  	testsuite.RunAllLocalFSTests(t, tester{})
    63  }