wip: 重新整理 install cmd

This commit is contained in:
zhaoyupeng
2026-01-13 20:13:29 +08:00
parent fcbaa5be2f
commit 760784a5ac
15 changed files with 957 additions and 665 deletions

44
pkg/syscheck/cpu_test.go Normal file
View File

@@ -0,0 +1,44 @@
package syscheck
import (
"testing"
)
func TestGetCPUInfo(t *testing.T) {
info, err := GetCPUInfo(t.Context())
if err != nil {
t.Fatalf("Failed to get CPU info: %v", err)
}
// Validate CPU cores
if info.Cores <= 0 {
t.Errorf("expected CPU cores > 0, got %d", info.Cores)
}
// Validate CPU frequency (should be reasonable, e.g., 500MHz - 10000MHz)
if info.FrequencyMHz <= 0 {
t.Errorf("expected CPU frequency > 0, got %.2f", info.FrequencyMHz)
}
if info.FrequencyMHz < 500 || info.FrequencyMHz > 10000 {
t.Logf("Warning: CPU frequency seems unusual: %.2f MHz", info.FrequencyMHz)
}
// Log CPU information
t.Logf("CPU Cores: %d", info.Cores)
t.Logf("CPU Frequency: %.2f MHz (%.2f GHz)", info.FrequencyMHz, info.FrequencyMHz/1000)
t.Logf("AES-NI Support: %v", info.SupportAES)
t.Logf("x86-64-v2 Compatible: %v", info.IsX86V2)
// Log feature support
if info.SupportAES {
t.Log("✓ CPU supports AES-NI hardware acceleration")
} else {
t.Log("✗ CPU does not support AES-NI")
}
if info.IsX86V2 {
t.Log("✓ CPU is x86-64-v2 compatible (SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT)")
} else {
t.Log("✗ CPU is not x86-64-v2 compatible")
}
}