From Fedora Project Wiki

Revision as of 03:35, 18 August 2023 by Sumantrom (talk | contribs) (Created page with "{{QA/Test_Case |description=dotconf is a library for reading configuration files, which are similar to those used by the Apache HTTPD server. dotconf allows you to read and manage configuration files in your applications.This test case ensures that the `dotconf` library is working as expected. It verifies the ability to create, read, and parse configuration files using `dotconf`. |setup= # Install the version of Fedora that is to be tested on a bare metal or virtual syst...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

dotconf is a library for reading configuration files, which are similar to those used by the Apache HTTPD server. dotconf allows you to read and manage configuration files in your applications.This test case ensures that the dotconf library is working as expected. It verifies the ability to create, read, and parse configuration files using dotconf.

Setup

  1. Install the version of Fedora that is to be tested on a bare metal or virtual system.
  2. Install the dotconf package using the command: sudo dnf install dotconf.
  3. Install a C compiler and make utility, for example: sudo dnf install gcc make.

How to test

  1. Create a simple C program that uses the dotconf library to read a configuration file:
   ## Write the following sample C program to a file named config_test.c:
   `c
   #include <dotconf.h>
   
   static dotconf_callback_t callback;
   
   static DOTCONF_CB(callback) {
       printf("Option %s is set to %s\n", cmd->name, cmd->data.str);
       return NULL;
   }
   
   int main(int argc, char **argv) {
       dotconf_t * configfile;
   
       static const configoption_t options[] = {
           {"TestOption", ARG_STR, callback, NULL, 0},
           LAST_OPTION
       };
   
       configfile = dotconf_create("test.conf", options, NULL, CASE_INSENSITIVE);
       if (!configfile) {
           printf("Error creating config file\n");
           return 1;
       }
   
       if (dotconf_command_loop(configfile) == 0)
           printf("Config file processed successfully\n");
   
       dotconf_cleanup(configfile);
       return 0;
   }
   `
  1. Create a simple configuration file named test.conf with the following content:
   `
   TestOption "Hello World"
   `
  1. Compile the C program:
   ## gcc config_test.c -ldotconf -o config_test
  1. Run the compiled program:
   ## ./config_test

Expected Results

  1. The dotconf package installs without error.
  2. The C program compiles successfully without errors.
  3. The compiled program runs and outputs: "Option TestOption is set to Hello World", followed by "Config file processed successfully".

Optional

  1. Test with more complex configuration files (e.g., with nested sections, different types of values, etc.).
  2. Test error handling in the dotconf library (e.g., missing configuration files, syntax errors in configuration files, etc.).
  3. Test the behavior of the dotconf library when the configuration file is extremely large.