| 1145 | } |
| 1146 | |
| 1147 | int main(int argc, const char ** argv) { |
| 1148 | fprintf(stdout, "Running llguidance integration tests...\n"); |
| 1149 | |
| 1150 | if (argc != 2) { |
| 1151 | fprintf(stderr, "Usage: %s <vocab-file>\n", argv[0]); |
| 1152 | return 1; |
| 1153 | } |
| 1154 | |
| 1155 | const char * vocab_file = argv[1]; |
| 1156 | |
| 1157 | fprintf(stderr, "reading vocab from: '%s'\n", vocab_file); |
| 1158 | |
| 1159 | llama_model * model; |
| 1160 | llama_context * ctx; |
| 1161 | |
| 1162 | llama_backend_init(); |
| 1163 | |
| 1164 | // load the vocab |
| 1165 | { |
| 1166 | auto mparams = llama_model_default_params(); |
| 1167 | |
| 1168 | mparams.vocab_only = true; |
| 1169 | |
| 1170 | model = llama_model_load_from_file(vocab_file, mparams); |
| 1171 | |
| 1172 | if (model == NULL) { |
| 1173 | fprintf(stderr, "%s: error: failed to load vocab '%s'\n", __func__, vocab_file); |
| 1174 | return 1; |
| 1175 | } |
| 1176 | |
| 1177 | // needed? |
| 1178 | auto cparams = llama_context_default_params(); |
| 1179 | |
| 1180 | ctx = llama_init_from_model(model, cparams); |
| 1181 | |
| 1182 | if (ctx == NULL) { |
| 1183 | fprintf(stderr, "%s: error: failed to load vocab '%s'\n", __func__, vocab_file); |
| 1184 | llama_model_free(model); |
| 1185 | return 1; |
| 1186 | } |
| 1187 | } |
| 1188 | |
| 1189 | vocab = llama_model_get_vocab(model); |
| 1190 | |
| 1191 | test_simple_grammar(); |
| 1192 | test_complex_grammar(); |
| 1193 | test_special_chars(); |
| 1194 | test_quantifiers(); |
| 1195 | test_json_schema(); |
| 1196 | |
| 1197 | test_sampler_chain(); |
| 1198 | |
| 1199 | llama_free(ctx); |
| 1200 | llama_model_free(model); |
| 1201 | |
| 1202 | fprintf(stdout, "All tests passed.\n"); |
| 1203 | return 0; |
| 1204 | } |
nothing calls this directly
no test coverage detected