Esempio n. 1
0
func TestLog(t *testing.T) {
	// Dump for manual inspection.
	supp, err := DetectSupportedSyscalls()
	if err != nil {
		t.Skipf("skipping: %v", err)
	}
	t.Logf("unsupported:")
	for _, c := range sys.Calls {
		s, ok := supp[c]
		if ok && !s {
			t.Fatalf("map contains false value")
		}
		if !s {
			t.Logf("\t%v", c.Name)
		}
	}
	trans := sys.TransitivelyEnabledCalls(supp)
	t.Logf("transitively unsupported:")
	for _, c := range sys.Calls {
		s, ok := trans[c]
		if ok && !s {
			t.Fatalf("map contains false value")
		}
		if !s && supp[c] {
			t.Logf("\t%v", c.Name)
		}
	}
}
Esempio n. 2
0
func buildCallList() map[*sys.Call]bool {
	calls, err := host.DetectSupportedSyscalls()
	if err != nil {
		log.Printf("failed to detect host supported syscalls: %v", err)
		for _, c := range sys.Calls {
			calls[c] = true
		}
	}
	for _, c := range sys.Calls {
		if !calls[c] {
			log.Printf("disabling unsupported syscall: %v", c.Name)
		}
	}
	trans := sys.TransitivelyEnabledCalls(calls)
	for c := range calls {
		if !trans[c] {
			log.Printf("disabling transitively unsupported syscall: %v", c.Name)
			delete(calls, c)
		}
	}
	return calls
}
Esempio n. 3
0
func buildCallList(enabledCalls string) map[*sys.Call]bool {
	calls := make(map[*sys.Call]bool)
	if enabledCalls != "" {
		for _, id := range strings.Split(enabledCalls, ",") {
			n, err := strconv.ParseUint(id, 10, 64)
			if err != nil || n >= uint64(len(sys.Calls)) {
				panic(fmt.Sprintf("invalid syscall in -calls flag: '%v", id))
			}
			calls[sys.Calls[n]] = true
		}
	} else {
		for _, c := range sys.Calls {
			calls[c] = true
		}
	}

	if supp, err := host.DetectSupportedSyscalls(); err != nil {
		logf(0, "failed to detect host supported syscalls: %v", err)
	} else {
		for c := range calls {
			if !supp[c] {
				logf(1, "disabling unsupported syscall: %v", c.Name)
				delete(calls, c)
			}
		}
	}

	trans := sys.TransitivelyEnabledCalls(calls)
	for c := range calls {
		if !trans[c] {
			logf(1, "disabling transitively unsupported syscall: %v", c.Name)
			delete(calls, c)
		}
	}
	return calls
}