File: test_eai_errno_defaults.ml

package info (click to toggle)
ocaml-posix 4.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,384 kB
  • sloc: ml: 9,495; ansic: 45; sh: 14; makefile: 5
file content (71 lines) | stat: -rw-r--r-- 2,716 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
open Posix_socket

(* get_value is now generated from eai_errno_defaults.mli in Test_get_value module *)

let () =
  Printf.printf "=== POSIX Errno Default Values Test ===\n\n";

  (* Print system information *)
  Printf.printf "Platform: system=%s\n\n" Posix_base.System_detect.system;

  Printf.printf "Comparing default eai errno values with system values...\n\n";

  (* Compare regular eai errno values *)
  Printf.printf "eai_errno constants:\n";
  Printf.printf "%-20s | %-10s | %-10s | %-10s | %s\n" "Name" "Default" "System"
    "Native" "Status";
  Printf.printf "%s\n" (String.make 77 '-');

  let matching = ref 0 in
  let different = ref 0 in
  let different_list = ref [] in

  List.iter
    (fun (name, default_value) ->
      let value = Test_get_value.get_value name in
      let int_value = Posix_socket.int_of_error value in
      let is_native_val = is_native value in
      let native_str = if is_native_val then "YES" else "NO" in
      let status, mark =
        if int_value = default_value then (
          incr matching;
          ("MATCH", "  "))
        else (
          incr different;
          different_list := (name, default_value, int_value) :: !different_list;
          ("DIFFERENT", "**"))
      in
      Printf.printf "%s%-20s | %-10d | %-10d | %-10s | %s\n" mark name
        default_value int_value native_str status)
    Eai_errno_defaults.eai_errno_defaults;

  (* Summary *)
  Printf.printf "\n=== Summary ===\n";
  Printf.printf "Total eai_errno constants tested: %d\n"
    (List.length Eai_errno_defaults.eai_errno_defaults);
  Printf.printf "Values matching defaults: %d\n" !matching;
  Printf.printf "Values different from defaults: %d\n" !different;

  if !different > 0 then (
    Printf.printf "\nValues that differ from defaults:\n";
    List.iter
      (fun (name, default_val, system_val) ->
        Printf.printf "  %-20s: default=%d, system=%d (diff=%d)\n" name
          default_val system_val (system_val - default_val))
      (List.rev !different_list));

  Printf.printf
    "\nNote: The 'Native' column shows whether the eai errno is natively\n";
  Printf.printf
    "defined by the system (YES) or using a placeholder fallback (NO).\n";
  Printf.printf "\nValues that match the defaults may either:\n";
  Printf.printf "  1. Be natively defined by the system with that value, OR\n";
  Printf.printf
    "  2. Not be defined by the system and use the fallback default value\n";
  Printf.printf
    "\nValues that differ from defaults are definitely defined by the system.\n";
  Printf.printf
    "Use the is_native() function to distinguish between cases 1 and 2.\n";

  Printf.printf
    "\nTest completed successfully (informational only, no failures)\n"