github.com/jaypipes/ghw@v0.21.1/testdata/testdata.go (about)

     1  //
     2  // Use and distribution licensed under the Apache license version 2.
     3  //
     4  // See the COPYING file in the root project directory for full text.
     5  //
     6  
     7  package testdata
     8  
     9  import (
    10  	"fmt"
    11  	"path/filepath"
    12  	"runtime"
    13  )
    14  
    15  func SnapshotsDirectory() (string, error) {
    16  	_, file, _, ok := runtime.Caller(0)
    17  	if !ok {
    18  		return "", fmt.Errorf("Cannot retrieve testdata directory")
    19  	}
    20  	basedir := filepath.Dir(file)
    21  	return filepath.Join(basedir, "snapshots"), nil
    22  }
    23  
    24  func SamplesDirectory() (string, error) {
    25  	_, file, _, ok := runtime.Caller(0)
    26  	if !ok {
    27  		return "", fmt.Errorf("Cannot retrieve testdata directory")
    28  	}
    29  	basedir := filepath.Dir(file)
    30  	return filepath.Join(basedir, "samples"), nil
    31  }
    32  
    33  func PCIDBChroot() string {
    34  	_, file, _, ok := runtime.Caller(0)
    35  	if !ok {
    36  		panic("cannot retrieve testdata directory")
    37  	}
    38  	basedir := filepath.Dir(file)
    39  	return filepath.Join(basedir, "usr", "share", "hwdata", "pci.ids")
    40  }