summaryrefslogtreecommitdiffstats
path: root/ini/ini_parse_ut.c
Commit message (Collapse)AuthorAgeFilesLines
* Expose collected stat dataDmitri Pal2013-01-281-0/+17
| | | | | Added a new top level interface funtion and a unit test for it.
* Check is the stats we collectedDmitri Pal2013-01-281-0/+30
| | | | | This patch corrects a problem related to stats being accessed and evaluated without being initialized.
* Unit test for parsing flags.Dmitri Pal2013-01-241-0/+83
| | | | Added unit test.
* More interface refactoringDmitri Pal2013-01-241-12/+12
| | | | | | | | | | | | | | | | | I also realized that error list processing should not be bound to the file object. This patch corrects that by moving the error_list and corresponding count from file object to the config object. Things updated by the patch: 1. The internal variables are moved from file obj to config obj. 2. The external header is updated to reflect the change 3. Functions are moved from file obj module to config obj module. 4. Parser code is updated because error validation was in the wrong place 5. Unit test is adjusted to get error list from the right object. I had to adjust the copy function for the config object. Copy function does not copy over the error list.
* Introducing parsing flagsDmitri Pal2013-01-241-0/+6
| | | | | | | | | | | | | | | | 1. Added definition of the parsing flags to the header. 2. Added new argument to the parser. 3. Added function to check the correctness of the line. 4. Added new constants and strings for errors. 5. Refactored function that handles spaces. 6. Moved handle_space since it now calls handle_kvp. 7. Updated handle_kvp to trim spaces at the beginning. 8. Adjusted line inspection to handle any space character. 9. Adjusted exising unit tests. Added parameter to the call. 10. Found couple places where there was a space at the end of the line and cleaned them. The additional unit tests will be added in the follow up patch.
* Refactor interface a bitDmitri Pal2013-01-241-18/+17
| | | | | | | | | | | | | | | | | After some evaluation it became apparent that error level and collision flags should not be a part of the fileobj but rather passed directly to the parser function. This way the interface is more clean and logical. This patch: 1) Removes the error level and collision flags from the fileobj 2) Moves validation function from ini_fileobj.c to ini_configobj.c where it belongs. 3) Moves error level and collision flags arguments from file open function to the parser function. 4) The internals of the file obj are cleaned 5) Validation of the arguments is moved to parser function. 6) Unit tests are updated.
* Replacing sprintf with snprintfDmitri Pal2013-01-241-45/+58
| | | | | | | | Replaced sprintf in the unit test. Defined constants for sizes and used them. Wrpapped lines where noticed that they are longer than 80. Added comments to the places where sprintf is still used but it is safe to use.
* Fixing headersDmitri Pal2013-01-241-1/+1
| | | | | | | Move GNU_SOUCE definition to configure.ac Change all headers to use config.h. Move config.h to the top. Remove errno.h if it is not needed.
* Add INI_GET_LAST_VALUEDmitri Pal2013-01-071-3/+29
| | | | | Refactored the defines to enum. Added support for fetching last value from the section.
* Fix CLANG errors in unit testDmitri Pal2013-01-071-5/+4
|
* Update unit testsDmitri Pal2012-12-061-6/+368
| | | | | | The parser unit test have been updated to execute the changes in the parser code. A new test was added to execute merge code in all possible modes.
* Remove code that allows dup sectionsDmitri Pal2012-12-061-15/+25
| | | | | | | | | | | | Duplicate sections in the config tree is a bad idea. After more evaluation I decided to not allow more than one section with the same name to be acceptable in the resulting object. All duplicate sections need to be processed so that only one section is left as a result. The collision flags control that. It is OK to remove it as this code has not been released yet. I also spotted that unit test does not exit if the system() call was successful but the command it invoked was not. Fixed that. Also fixed couple spelling mistakes here and there.
* Added new tests for the multi value keysDmitri Pal2012-10-171-0/+1133
|
* Fix permission checking unit testStephen Gallagher2012-10-171-37/+116
| | | | | | | | | The unit test was broken. The wrong function was used. To make sure everything is correct I also added a convenience function to print the internals if the file context object. The unit test is fixed to use relative paths consitently. Also added nice statements at the beggining and the end of the unit test functions where they were missing.
* Properly handle file permissions for ini_parse_ut startup_test()Stephen Gallagher2012-05-151-17/+6
|
* Fix issue when running make distcheckStephen Gallagher2012-05-151-11/+5
| | | | | | | | When running 'make distcheck', all files in the $srcdir are set to read-only, to ensure that the build does not modify the source. However, this broke our ability to test file permissions. We will now copy the file to the builddir and do the tests there, where we have control.
* Initialize variables in loopsDmitri Pal2012-04-051-0/+4
| | | | | | | | | It occured to me that one of the issues that Coverity did not like (and I could not understand what it is complaining about) is related to intializing the variables in the loop. This patch adds initialization in the loops. Also there was an initialization missing in the ini_configobj.c
* Rename error print functionDmitri Pal2012-04-051-4/+4
| | | | | | | | | | All config file processing functions start with "ini_config". The only function that does not comply is ini_print_errors. We can't rename it since it is a part of the current active interface. I marked that function needs to be removed when we remove old interface and created a copy with the correct name. I also updated unit test accordingly.
* Tests for access and changesDmitri Pal2012-04-051-0/+283
| | | | | Patch adds two functions. One tests permissions, another validates if the file has changed or not.
* Separate close and destroyDmitri Pal2012-04-051-5/+5
| | | | Allow closing file without destroying the context.
* Test for all section merge modesDmitri Pal2012-04-051-13/+201
| | | | | | New test reads smerge.conf in all possible modes and compares the combined result with the sexpect.conf function.
* Test DETECT mode and use new fileDmitri Pal2012-04-051-7/+23
| | | | | | Patch adds smerge.conf file to the list of files to test and adds test for the DETECT mode for inidividual values.
* Adding missing constDmitri Pal2011-01-031-1/+1
| | | | One liner to eliminate compilation warning.
* Correcting paths to test filesDmitri Pal2010-12-211-14/+6
| | | | | | | | The paths to test files did not work in parallel build or 'make diskcheck' cases. Now they are corrected. All temp files are created in the build directory and read from there.
* Allow merging valuesDmitri Pal2010-12-211-0/+203
| | | | | | | | | | | | | | | | This patch is the first pass at merging functionality. It implements merging of values that belong to the same section. Patch includes: * Definition of merge flags in doxy format * Definition of the masks in internal header * Changes to parser to handle the merging of values. * Also swithed parser to not use ini_config.h as I want to switch implementation of the current interface to new interface at some point. * New unit test was created. * New config file for this unit test was added to ini.d Main code changes are in ini_parse.c
* New copy and folding functionalityDmitri Pal2010-12-211-38/+91
| | | | | | | | | | | | | | | | * Added method to copy configuration. * Added unit test for it. * Added method to reset boandary for the whole configuration. * Added unit test for it. * Unit test now can read a file save it read again and save. Both saves produce same files! * Reworked the way the parser was dealing with empty lines. It was sutting off the value in the middle if the folded line consisted of just spaces.
* Fix overflow in ini_parse unit testSumit Bose2010-09-231-3/+2
|
* Introducing configuration file objectDmitri Pal2010-09-221-19/+24
| | | | | | | | The patch contains two major pieces of work: * The beginning of the new INI interface significantly re-thought and reworked. * The implementation of the file object. Parsing was adjusted to use this object.
* Starting to consolidate the new interface in one placeDmitri Pal2010-09-221-3/+2
| | | | | | | | | | I realized that the new high level interface should be defined in one file instead of being scattered in many headers. I would have to eventuallu eliminate ini_configobj.h too and move everything to the new interface in ini_config.h. This patch renames couple functions to be consistent with the naming convention and removes ini_parse.h header.
* New INI parserDmitri Pal2010-09-221-0/+209
The parser is added to the existing module. The old parsing functuion will be removed when we switch to the new interface. Parser logic: * There is one high level function that wraps the parser interface. It is at the bottom of the module. ini_parse_config(); * Internally it creates a perser object and then runs parser on it. * At the end parser object is destroyed. * This object stores the state of the parser. * The parser has an action queue * There are several actions that parser can perform - read line - inspect read line - record an error - process last comment in the file (POST) * Each action handler determines what to do next depending upon what has happened. * Read handler reads lines and enqueues inspection action in case of success or error action in case of failure. * Inspection action parses last read line and treats it either is a: * Comment * Section * New key + value * Continuation of the value In case of error the error action is enqueued. * Error can be fatal or non fatal. It depend on the error_level flag passed in. If the error is non fatal the read action is enqueued otherwise parser stops. * The POST action is a special action to handle comment at the bottom of the file. The comment is stored with the value it preceeds so in case there is a comment at the bottom of the file a special value needs to be created to hold just the comment.