summaryrefslogtreecommitdiff
path: root/tests/smoke.cmake
blob: 3992b6b2846e41d9dd3c6bb20ce7643446168d78 (plain)
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
if(NOT DEFINED SERVER OR NOT EXISTS "${SERVER}")
  message(FATAL_ERROR "SERVER does not name a built tiny-convmem-mcp executable")
endif()
if(NOT DEFINED INPUT OR NOT EXISTS "${INPUT}")
  message(FATAL_ERROR "INPUT does not name the smoke-test fixture")
endif()
if(NOT DEFINED DATA_DIR)
  message(FATAL_ERROR "DATA_DIR is required")
endif()

file(REMOVE_RECURSE "${DATA_DIR}")

execute_process(
  COMMAND "${SERVER}" --data-dir "${DATA_DIR}"
  INPUT_FILE "${INPUT}"
  OUTPUT_VARIABLE server_output
  ERROR_VARIABLE server_error
  RESULT_VARIABLE server_result
  TIMEOUT 10
)

if(NOT server_result EQUAL 0)
  message(FATAL_ERROR
    "Server exited with ${server_result}.\nstdout: ${server_output}\nstderr: ${server_error}"
  )
endif()

foreach(expected
    "\"protocolVersion\":\"2024-11-05\""
    "\"serverInfo\""
    "\"capabilities\""
    "\"name\":\"write_message\""
    "\"name\":\"read_messages\""
    "\"name\":\"search_messages\""
    "\"name\":\"delete_message\""
    "\"name\":\"rebuild_index\""
    "\"name\":\"get_system_health\""
    "\"metadata_json\""
    "\"type\":\"text\""
    "\\\"status\\\":\\\"OK\\\""
    "\\\"code\\\":\\\"VALIDATION_ERROR\\\""
    "hello durable memory"
  )
  string(FIND "${server_output}" "${expected}" match_position)
  if(match_position EQUAL -1)
    message(FATAL_ERROR
      "Expected ${expected} in MCP output.\nstdout: ${server_output}\nstderr: ${server_error}"
    )
  endif()
endforeach()

message(STATUS "MCP initialize, six-tool listing, write, read, search, rebuild, and health succeeded")