|
|
@@ -0,0 +1,74 @@
|
|
|
+MODULE test_sysinfo ;
|
|
|
+
|
|
|
+(*
|
|
|
+ m2SDL3 smoke tests, no window needed:
|
|
|
+ - power: SDL_GetPowerInfo returns a known state id.
|
|
|
+ - locale: preferred-locales list decodes (first language nonempty).
|
|
|
+ - filesystem: base path + current directory are nonempty strings.
|
|
|
+ SDL-allocated results are released with SDL_free.
|
|
|
+*)
|
|
|
+
|
|
|
+FROM SYSTEM IMPORT ADDRESS;
|
|
|
+FROM SDL3Power IMPORT SDL_GetPowerInfo,
|
|
|
+ PowerError, PowerUnknown, PowerOnBattery,
|
|
|
+ PowerNoBattery, PowerCharging, PowerCharged;
|
|
|
+FROM SDL3Locale IMPORT SDLLocale, LocalePtr, LocaleVecPtr,
|
|
|
+ SDL_GetPreferredLocales;
|
|
|
+FROM SDL3Filesystem IMPORT SDL_GetBasePath, SDL_GetCurrentDirectory;
|
|
|
+FROM SDL3Stdinc IMPORT SDL_free;
|
|
|
+FROM SDL3Utils IMPORT CStrToM2;
|
|
|
+FROM libc IMPORT printf;
|
|
|
+
|
|
|
+VAR
|
|
|
+ secs, pct, state, n, i: INTEGER;
|
|
|
+ vec: LocaleVecPtr;
|
|
|
+ entry: LocalePtr;
|
|
|
+ p: ADDRESS;
|
|
|
+ buf: ARRAY [0..255] OF CHAR;
|
|
|
+
|
|
|
+PROCEDURE Fail (msg: ARRAY OF CHAR);
|
|
|
+BEGIN
|
|
|
+ printf("FAIL test_sysinfo: %s\n", msg);
|
|
|
+ HALT(1)
|
|
|
+END Fail;
|
|
|
+
|
|
|
+BEGIN
|
|
|
+ (* power *)
|
|
|
+ secs := 0; pct := 0;
|
|
|
+ state := SDL_GetPowerInfo(secs, pct);
|
|
|
+ printf("power state=%d secs=%d pct=%d\n", state, secs, pct);
|
|
|
+ IF (state < PowerError) OR (state > PowerCharged) THEN
|
|
|
+ Fail("power state out of range")
|
|
|
+ END;
|
|
|
+
|
|
|
+ (* locale *)
|
|
|
+ n := 0;
|
|
|
+ vec := SDL_GetPreferredLocales(n);
|
|
|
+ IF vec = NIL THEN Fail("locale list NIL") END;
|
|
|
+ printf("locales: %d\n", n);
|
|
|
+ IF n <= 0 THEN Fail("locale count not positive") END;
|
|
|
+ IF n > 256 THEN Fail("locale count over 256") END;
|
|
|
+ entry := vec^[0];
|
|
|
+ IF entry = NIL THEN Fail("first locale NIL") END;
|
|
|
+ CStrToM2(entry^.language, buf);
|
|
|
+ printf("first locale: %s\n", buf);
|
|
|
+ IF buf[0] = 0C THEN Fail("first language empty") END;
|
|
|
+ FOR i := 0 TO n - 1 DO
|
|
|
+ IF vec^[i] = NIL THEN Fail("locale entry NIL") END
|
|
|
+ END;
|
|
|
+ SDL_free(vec);
|
|
|
+
|
|
|
+ (* filesystem *)
|
|
|
+ p := SDL_GetBasePath();
|
|
|
+ CStrToM2(p, buf);
|
|
|
+ SDL_free(p);
|
|
|
+ printf("base: %s\n", buf);
|
|
|
+ IF buf[0] = 0C THEN Fail("base path empty") END;
|
|
|
+ p := SDL_GetCurrentDirectory();
|
|
|
+ CStrToM2(p, buf);
|
|
|
+ SDL_free(p);
|
|
|
+ printf("cwd: %s\n", buf);
|
|
|
+ IF buf[0] = 0C THEN Fail("cwd empty") END;
|
|
|
+
|
|
|
+ printf("PASS test_sysinfo\n")
|
|
|
+END test_sysinfo.
|