Commit 9e66d16a authored by Lev Walkin's avatar Lev Walkin

infer skeletons level

parent 819c832b
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#define TOP_SRCDIR_S STRINGIFY_MACRO(TOP_SRCDIR) #define TOP_SRCDIR_S STRINGIFY_MACRO(TOP_SRCDIR)
#endif #endif
static int check(const char *fname, static int check(int skeletons_hier_level, const char *fname,
enum asn1p_flags parser_flags, enum asn1p_flags parser_flags,
enum asn1f_flags fixer_flags); enum asn1f_flags fixer_flags);
static int post_fix_check(asn1p_t *asn); static int post_fix_check(asn1p_t *asn);
...@@ -41,6 +41,7 @@ main(int ac, char **av) { ...@@ -41,6 +41,7 @@ main(int ac, char **av) {
enum asn1p_flags parser_flags = A1P_NOFLAGS; enum asn1p_flags parser_flags = A1P_NOFLAGS;
enum asn1f_flags fixer_flags = A1F_NOFLAGS; enum asn1f_flags fixer_flags = A1F_NOFLAGS;
const char *filename; const char *filename;
int skeletons_hier_level = 1;
size_t len; size_t len;
int ret; int ret;
...@@ -66,7 +67,10 @@ main(int ac, char **av) { ...@@ -66,7 +67,10 @@ main(int ac, char **av) {
if(ret == -1) if(ret == -1)
fprintf(stderr, "%s: %s\n", asn1_tests_dir, strerror(errno)); fprintf(stderr, "%s: %s\n", asn1_tests_dir, strerror(errno));
assert(ret == 0); assert(ret == 0);
(void)chdir("tests"); /* For some reasons, tests could be hidden. */ /* For some reasons, tests could be hidden under extra tests dir. */
if(chdir("tests") == 0) {
skeletons_hier_level++;
}
#ifdef _WIN32 #ifdef _WIN32
dir = _findfirst("*.asn1", &c_file); dir = _findfirst("*.asn1", &c_file);
assert(dir != -1L); assert(dir != -1L);
...@@ -92,7 +96,7 @@ main(int ac, char **av) { ...@@ -92,7 +96,7 @@ main(int ac, char **av) {
len = strlen(filename); len = strlen(filename);
if(len <= 5 || strcmp(filename + len - 5, ".asn1")) if(len <= 5 || strcmp(filename + len - 5, ".asn1"))
continue; continue;
ret = check(filename, parser_flags, fixer_flags); ret = check(skeletons_hier_level, filename, parser_flags, fixer_flags);
if(ret) { if(ret) {
fprintf(stderr, "FAILED: %s\n", fprintf(stderr, "FAILED: %s\n",
filename); filename);
...@@ -117,7 +121,7 @@ main(int ac, char **av) { ...@@ -117,7 +121,7 @@ main(int ac, char **av) {
} else { } else {
int i; int i;
for(i = 1; i < ac; i++) { for(i = 1; i < ac; i++) {
ret = check(av[i], parser_flags, fixer_flags); ret = check(skeletons_hier_level, av[i], parser_flags, fixer_flags);
if(ret) { if(ret) {
fprintf(stderr, "FAILED: %s\n", av[i]); fprintf(stderr, "FAILED: %s\n", av[i]);
failed++; failed++;
...@@ -137,7 +141,7 @@ main(int ac, char **av) { ...@@ -137,7 +141,7 @@ main(int ac, char **av) {
} }
static int static int
check(const char *fname, check(int skeletons_hier_level, const char *fname,
enum asn1p_flags parser_flags, enum asn1p_flags parser_flags,
enum asn1f_flags fixer_flags) { enum asn1f_flags fixer_flags) {
asn1p_t *asn; asn1p_t *asn;
...@@ -196,7 +200,10 @@ check(const char *fname, ...@@ -196,7 +200,10 @@ check(const char *fname,
if(r_value == 0) { if(r_value == 0) {
asn1p_t *std_asn; asn1p_t *std_asn;
std_asn = asn1p_parse_file("../skeletons/standard-modules/ASN1C-UsefulInformationObjectClasses.asn1", A1P_NOFLAGS); std_asn = asn1p_parse_file(skeletons_hier_level == 1
? "../skeletons/standard-modules/ASN1C-UsefulInformationObjectClasses.asn1"
: "../../skeletons/standard-modules/ASN1C-UsefulInformationObjectClasses.asn1"
, A1P_NOFLAGS);
if(std_asn) { if(std_asn) {
asn1p_module_t *mod; asn1p_module_t *mod;
while((mod = TQ_REMOVE(&(std_asn->modules), mod_next))) { while((mod = TQ_REMOVE(&(std_asn->modules), mod_next))) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment