From 757bb6b08bb9762100d65e3f7271621aa35f7002 Mon Sep 17 00:00:00 2001
From: Dmitri Pal <dpal@redhat.com>
Date: Thu, 10 Oct 2013 22:51:22 -0400
Subject: [PATCH 09/13] [INI] Updated unit test for UTF8 conversion

Patch adds new test files and bom creation function.
---
 ini/ini.d/real16be.conf |  Bin 0 -> 3288 bytes
 ini/ini.d/real16le.conf |  Bin 0 -> 3288 bytes
 ini/ini.d/real32be.conf |  Bin 0 -> 6576 bytes
 ini/ini.d/real32le.conf |  Bin 0 -> 6576 bytes
 ini/ini.d/real8.conf    |   70 +++++++++++++++++++++++++++++++++++++++++++++++
 ini/ini_parse_ut.c      |   35 +++++++++++++++++++++++
 6 files changed, 105 insertions(+), 0 deletions(-)
 create mode 100644 ini/ini.d/real16be.conf
 create mode 100644 ini/ini.d/real16le.conf
 create mode 100644 ini/ini.d/real32be.conf
 create mode 100644 ini/ini.d/real32le.conf
 create mode 100644 ini/ini.d/real8.conf

diff --git a/ini/ini.d/real16be.conf b/ini/ini.d/real16be.conf
new file mode 100644
index 0000000000000000000000000000000000000000..2e81831eda146b21752c73204b10da4449a51b6c
GIT binary patch
diff --git a/ini/ini.d/real16le.conf b/ini/ini.d/real16le.conf
new file mode 100644
index 0000000000000000000000000000000000000000..83038bafb04b3f6dc3f14be58791ca4aba4ec215
GIT binary patch
diff --git a/ini/ini.d/real32be.conf b/ini/ini.d/real32be.conf
new file mode 100644
index 0000000000000000000000000000000000000000..eeb0dbf1b55411cba8a88297e7cac3d8d04ef431
GIT binary patch
diff --git a/ini/ini.d/real32le.conf b/ini/ini.d/real32le.conf
new file mode 100644
index 0000000000000000000000000000000000000000..453a2ad25f09b28f18a1cef08b61cedac6cb9996
GIT binary patch
diff --git a/ini/ini.d/real8.conf b/ini/ini.d/real8.conf
new file mode 100644
index 0000000..a379f5d
--- /dev/null
+++ b/ini/ini.d/real8.conf
@@ -0,0 +1,70 @@
+﻿// This is a real file with some comments
+
+[config]
+version = 0.1
+
+/**/
+[monitor]
+description = Monitor Configuration
+sbusTimeout = 10
+sbusAddress = unix:path=/var/lib/sss/pipes/private/dbus
+servicePingTime = 10
+bad_number = 5a
+
+/* Service section defines
+ * which service are allowed.
+ */           
+[services]
+description = Local service configuration
+activeServices = dp, nss, pam, info
+
+[services/dp]
+description = Data Provider Configuration
+command = /usr/libexec/sssd/sssd_dp
+
+[services/nss]
+description = NSS Responder Configuration
+unixSocket = /var/lib/sss/pipes/nss
+command = /usr/libexec/sssd/sssd_nss
+
+[services/pam]
+command = /usr/libexec/sssd/sssd_pam
+description = PAM Responder Configuration
+unixSocket = /var/lib/sss/pipes/pam
+
+[services/info]
+description = InfoPipe Configuration
+command = ./sbin/sssd_info
+
+[domains]
+domainsOrder =  , LOCAL,          ,  EXAMPLE.COM, ,     SOMEOTHER.COM    ,  ,
+badarray =    ,   ,    ,   ,   ,
+somearray = ,
+someotherarray = , ;
+justdelim=:;,;
+yetanother = 
+
+[domains/LOCAL]
+description = Reserved domain for local configurations
+legacy = FALSE
+enumerate = 3
+
+[domains/EXAMPLE.COM]
+description = Example domain served by IPA 
+provider = ipa
+server = ipaserver1.example.com
+server = ipabackupserver.example.com
+legacy = FALSE
+server = otheripabackupserver.example.com
+enumerate = 0
+binary_test = '010203'
+binary_test_two = '0A0b0C'
+long_array = 1  2; 4' ;8p .16/ 32?
+double_array = 1.1  2.222222; .4' . ;8p .16/ -32?
+server = yetanotheripabackupserver.example.com
+empty_value =
+space_value = " "
+int32_t = -1000000000
+uint32_t = 3000000000
+int64_t = -1000000000123
+uint64_t = 3000000000123
diff --git a/ini/ini_parse_ut.c b/ini/ini_parse_ut.c
index 3a523af..6e98eb5 100644
--- a/ini/ini_parse_ut.c
+++ b/ini/ini_parse_ut.c
@@ -181,6 +181,11 @@ int read_save_test(void)
                             "ipa",
                             "test",
                             "smerge",
+                            "real8",
+                            "real16be",
+                            "real16le",
+                            "real32be",
+                            "real32le",
                             NULL };
 
     INIOUT(printf("<==== Read save test ====>\n"));
@@ -215,6 +220,11 @@ int read_again_test(void)
                             "ipa",
                             "test",
                             "smerge",
+                            "real8",
+                            "real16be",
+                            "real16le",
+                            "real32be",
+                            "real32le",
                             NULL };
 
     INIOUT(printf("<==== Read again test ====>\n"));
@@ -3010,6 +3020,28 @@ int comment_test(void)
     return EOK;
 }
 
+void create_boms(void)
+{
+    FILE *f;
+
+    f = fopen("bom2be","wb");
+    fprintf(f,"%c%c", 0xFE, 0xFF);
+    fclose(f);
+    f = fopen("bom2le","wb");
+    fprintf(f,"%c%c", 0xFF, 0xFE);
+    fclose(f);
+    f = fopen("bom4be","wb");
+    fprintf(f,"%c%c%c%c", 0x00, 0x00, 0xFE, 0xFF);
+    fclose(f);
+    f = fopen("bom4le","wb");
+    fprintf(f,"%c%c%c%c", 0xFF, 0xFE, 0x00, 0x00);
+    fclose(f);
+    f = fopen("bom3","wb");
+    fprintf(f,"%c%c%c", 0xEF, 0xBB, 0xBF);
+    fclose(f);
+}
+
+
 /* Main function of the unit test */
 int main(int argc, char *argv[])
 {
@@ -3036,6 +3068,9 @@ int main(int argc, char *argv[])
         if (var) verbose = 1;
     }
 
+    /* Create boms in case we want to create more test files */
+    create_boms();
+
     INIOUT(printf("Start\n"));
 
     while ((t = tests[i++])) {
-- 
1.7.1

