[YANGTOOLS-734] yang-system-test: -p directories are for dependency search Created: 04/Jan/17  Updated: 10/Apr/22  Resolved: 23/Feb/17

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Vratko Polak Assignee: Peter Kajsa
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 7480

 Description   

This request is not very compatible with YANGTOOLS-726 so that would need to use option different from -p.

Examining existing Yang validators, it turns out their focus is not on validating a whole set of Yang models, but on validating a single Yang file instead.
This single file is given as an argument (not -p option).

Of course most Yang modules are including other modules, so to ascertain validity those other modules should also be available. Thus a Yang validator needs to be able to search for dependencies, and -p directories are the locations the validator should search for the needed files in (defaulting to current working directory if no -p is given).

In order for yang-system-test to be used as a Yang validator in existing validation frameworks, it should honor the same semantics.

As a evidence, here [0] is description of -p in yanglint, and here [1] is how yangvalidator.com invokes pyang to validate a particular Yang file.

[0] https://github.com/CESNET/libyang/blob/master/tools/lint/main_ni.c#L50
[1] https://github.com/cmoberg/bottle-yang-extractor-validator/blob/master/bottle-yang-extractor-validator/main.py#L93

P.S.: For purpose of validation of single files, perhaps odl-yang-validator would be a better name than yang-system-test.



 Comments   
Comment by Vratko Polak [ 11/Jan/17 ]

As an example let us have these files present:
./to-test.yang
./deps/standard.yang
./deps/broken.yang

Where module to-test imports module standard, but not module broken. Assume that bronken.yang is broken and would cause a failure. Assume to-test.yang is correct and would pass.

Currently this call:
$ java -jar yangsystemtestlongname.jar -p deps to-test.yang
would attempt to add also ./deps/broken.yang and thus fail.

After fixing this. the same call would only add ./to-test.yang (because it is an explicit filename) and ./deps/standard.yang (discovered dependency), but not ./deps/broken.yang

In comparison, this call:
$ java -jar yangsystemtestlongname.jar to-test.yang
would fail, because the required import was not satisfied.

After copying ./deps/standard.yang to ./standard.yang the repeated call would again pass, as ./ is implicitly always present in the list of directories where dependencies are searched for.

Comment by Vratko Polak [ 11/Jan/17 ]

Aside of performance implications, this is also important for this case:
./to-test-no-imports.yang
./broken.yang

Comment by Viera Zelcamova [ 23/Jan/17 ]

due higher priorities for API freeze, moving for M5 Carbon.

Comment by Vratko Polak [ 23/Jan/17 ]

Most implementations of single module validators first scan all file names in -p directories to build a "library" of files, and when building a "schema context" they search and add files from that library only when needed to satisfy an import. Yangtools currently does not support such "library" behavior, so the fix is not trivial.

Comment by Peter Kajsa [ 30/Jan/17 ]

https://git.opendaylight.org/gerrit/#/c/51018/

Generated at Wed Feb 07 20:54:09 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.