add input mode unit-test
This commit is contained in:
@@ -154,7 +154,7 @@ int cm_read_table_file(struct cm_table_info_t* index,
|
||||
}
|
||||
}
|
||||
|
||||
free(table_file_buff);
|
||||
FREE(table_file_buff);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -241,14 +241,14 @@ int get_new_idx_path(long long current_version, const char *file_dir, char ***id
|
||||
}
|
||||
|
||||
if (strlen(namelist[i]->d_name) > 42) {
|
||||
fprintf(stderr, "config file %s filename too long,should like full_config_index.00000000000000000001",
|
||||
fprintf(stderr, "config file %s filename too long, should like full_config_index.000000000001\n",
|
||||
namelist[i]->d_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
int ret = sscanf(namelist[i]->d_name,"%[a-zA-Z]_config_index.%lld", update_str, &config_seq);
|
||||
if (ret != 2) {
|
||||
fprintf(stderr, "config file %s filename error,should like full_config_index.00000000000000000001",
|
||||
fprintf(stderr, "config file %s filename error, should like full_config_index.000000000001\n",
|
||||
namelist[i]->d_name);
|
||||
continue;
|
||||
}
|
||||
@@ -267,7 +267,7 @@ int get_new_idx_path(long long current_version, const char *file_dir, char ***id
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "config file %s,not full or inc config", namelist[i]->d_name);
|
||||
fprintf(stderr, "config file %s, not full or inc config\n", namelist[i]->d_name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,11 +294,11 @@ int get_new_idx_path(long long current_version, const char *file_dir, char ***id
|
||||
update_type = CM_UPDATE_TYPE_NONE;
|
||||
}
|
||||
|
||||
free(inc_file_idx);
|
||||
FREE(inc_file_idx);
|
||||
for (i = 0; i < n; i++) {
|
||||
free(namelist[i]);
|
||||
FREE(namelist[i]);
|
||||
}
|
||||
free(namelist);
|
||||
FREE(namelist);
|
||||
|
||||
return update_type;
|
||||
}
|
||||
@@ -322,7 +322,7 @@ void config_monitor_traverse(long long current_version, const char *idx_dir,
|
||||
for (i = 0; i < idx_path_num; i++) {
|
||||
int table_num = cm_read_cfg_index_file(idx_path_array[i], table_array, CM_MAX_TABLE_NUM);
|
||||
if (table_num < 0) {
|
||||
fprintf(stderr, "load %s failed, abandon udpate.", idx_path_array[i]);
|
||||
fprintf(stderr, "load %s failed, abandon update\n", idx_path_array[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -344,10 +344,10 @@ void config_monitor_traverse(long long current_version, const char *idx_dir,
|
||||
}
|
||||
|
||||
for (i = 0; i < idx_path_num; i++) {
|
||||
free(idx_path_array[i]);
|
||||
FREE(idx_path_array[i]);
|
||||
}
|
||||
|
||||
free(idx_path_array);
|
||||
FREE(idx_path_array);
|
||||
}
|
||||
|
||||
int load_maat_json_file(struct maat *maat_instance, const char *json_filename, char *err_str, size_t err_str_sz)
|
||||
@@ -361,13 +361,13 @@ int load_maat_json_file(struct maat *maat_instance, const char *json_filename, c
|
||||
size_t decrypted_buff_sz = 0;
|
||||
size_t uncompressed_buff_sz = 0;
|
||||
|
||||
fprintf(stdout, "Maat initial with JSON file %s, formating..", json_filename);
|
||||
fprintf(stdout, "Maat initial with JSON file %s, formating...\n", json_filename);
|
||||
|
||||
if (strlen(maat_instance->decrypt_key) && strlen(maat_instance->decrypt_algo)) {
|
||||
ret = decrypt_open(json_filename, maat_instance->decrypt_key, maat_instance->decrypt_algo,
|
||||
(unsigned char **)&decrypted_buff, &decrypted_buff_sz, err_str, err_str_sz);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Decrypt Maat JSON file %s failed.", json_filename);
|
||||
fprintf(stderr, "Decrypt Maat JSON file %s failed\n", json_filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -377,9 +377,9 @@ int load_maat_json_file(struct maat *maat_instance, const char *json_filename, c
|
||||
|
||||
if (maat_instance->maat_json_is_gzipped) {
|
||||
ret = gzip_uncompress(json_buff, json_buff_sz, &uncompressed_buff, &uncompressed_buff_sz);
|
||||
free(json_buff);
|
||||
FREE(json_buff);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Uncompress Maat JSON file %s failed.", json_filename);
|
||||
fprintf(stderr, "Uncompress Maat JSON file %s failed\n", json_filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ int load_maat_json_file(struct maat *maat_instance, const char *json_filename, c
|
||||
if (NULL == json_buff) {
|
||||
ret = load_file_to_memory(json_filename, &json_buff, &json_buff_sz);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Read Maat JSON file %s failed.", json_filename);
|
||||
fprintf(stderr, "Read Maat JSON file %s failed\n", json_filename);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -404,7 +404,7 @@ int load_maat_json_file(struct maat *maat_instance, const char *json_filename, c
|
||||
strlen(maat_instance->decrypt_key) ? maat_instance->decrypt_key : NULL,
|
||||
strlen(maat_instance->decrypt_algo) ? maat_instance->decrypt_algo : NULL);
|
||||
|
||||
free(json_buff);
|
||||
FREE(json_buff);
|
||||
json_buff = NULL;
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
@@ -414,11 +414,11 @@ int load_maat_json_file(struct maat *maat_instance, const char *json_filename, c
|
||||
strncpy(maat_instance->json_ctx.json_file, json_filename, sizeof(maat_instance->json_ctx.json_file));
|
||||
}
|
||||
|
||||
ret=stat(json_filename, &fstat_buf);
|
||||
ret = stat(json_filename, &fstat_buf);
|
||||
maat_instance->json_ctx.last_md5_time = fstat_buf.st_ctim;
|
||||
|
||||
md5_file(maat_instance->json_ctx.json_file, maat_instance->json_ctx.effective_json_md5);
|
||||
fprintf(stdout, "JSON file %s md5: %s, generate index file %s OK.",
|
||||
fprintf(stdout, "JSON file %s md5: %s, generate index file %s OK\n",
|
||||
maat_instance->json_ctx.json_file,
|
||||
maat_instance->json_ctx.effective_json_md5,
|
||||
maat_instance->json_ctx.iris_file);
|
||||
|
||||
Reference in New Issue
Block a user