MCPcopy Index your code
hub / github.com/containerd/containerd / waitForFileAndRead

Function waitForFileAndRead

integration/nri_test.go:1322–1343  ·  view source on GitHub ↗

helper functions Wait for a file to show up in the filesystem then read its content.

(path string, timeout time.Duration)

Source from the content-addressed store, hash-verified

1320
1321// Wait for a file to show up in the filesystem then read its content.
1322func waitForFileAndRead(path string, timeout time.Duration) ([]byte, error) {
1323 var (
1324 deadline = time.After(timeout)
1325 slack = 100 * time.Millisecond
1326 )
1327
1328WAIT:
1329 for {
1330 if _, err := os.Stat(path); err == nil {
1331 break WAIT
1332 }
1333 select {
1334 case <-deadline:
1335 return nil, fmt.Errorf("waiting for %s timed out", path)
1336 default:
1337 time.Sleep(slack)
1338 }
1339 }
1340
1341 time.Sleep(slack)
1342 return os.ReadFile(path)
1343}
1344
1345// getAvailableCpuset returns the set of online CPUs.
1346func getAvailableCpuset(t *testing.T) []string {

Calls 1

StatMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…