Private Profile Regression Test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

Here is my first stab at a profile regression test. Would anyone care to 
try it out? 26 of 162 tests fail right now. I also have windows source 
code and executable implementing the same tests if anyone is interested.

I believe one test (GetPrivateProfileStruct) fails because of structure 
packing differences between gcc and msvc since the test passes with the 
windows executable and fails with the winelib executable. I don't know 
for sure, though, and I definitely don't know how to fix it.

Anyhoo, please let me know what you think - are the tests sufficient, 
too much, not written properly? etc.

Thanks,

Josh Thielen

Changelog:
added profile regression tests for Get/WritePrivateProfilexxx functions

Added files:
wine/dlls/kernel/tests/profile.c
wine/dlls/kernel/tests/test.ini
wine/dlls/kernel/tests/compare1.ini
wine/dlls/kernel/tests/compare2.ini

Modified files:
wine/dlls/kernel/Makefile.in

License:
LGPL
/*
 * Unit tests for profile functions in Wine
 *
 * Copyright (c) 2002 Joshua Thielen
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 *
 *
 * TODO: INI file mappings in NT registry.
 *       public profile functions
 *       more extensive testing of Get/WritePrivateProfileStructA
 *       separate testing of 16-bit and unicode functions
 *
 * Test Files:
 *      test.ini is used to test the GetPrivateProfileX functions and is 
 *      also used as the base INI file for comparing against compare2.ini.
 *
 *      test.ini is copied to c:\
 *      test.ini is copied to the windows directory as winetest.ini
 *      
 *      compare1.ini and compare2.ini are compared against the output file,
 *      result.ini, of the WritePrivateProfileX test functions.
 *    
 *      The win.ini file is copied to the working directory and restored 
 *      at the end of the test.
 *
 */

#include <stdio.h>
#include "wine/test.h"
#include "winbase.h"
#include "winerror.h"

char winpath[1024];

/* 
 * Helper function to compare two files.
 *
 * Returns TRUE if files match.
 */
BOOL compare(char *file1, char *file2)
{
    HANDLE handle1, handle2;
    DWORD bytes_read1, bytes_read2;
    char buf1[1024], buf2[1024];
    BOOL ret = TRUE;

    handle1 = handle2 = INVALID_HANDLE_VALUE;
    handle1 = CreateFileA( file1, GENERIC_READ, 0, NULL, OPEN_EXISTING, 
            FILE_ATTRIBUTE_NORMAL, 0);
    handle2 = CreateFileA( file2, GENERIC_READ, 0, NULL, OPEN_EXISTING, 
            FILE_ATTRIBUTE_NORMAL, 0);

    if(handle1 == INVALID_HANDLE_VALUE) {
        trace("Could not open compare file 1\n");
        ret = FALSE;
    } else if(handle2 == INVALID_HANDLE_VALUE) { 
        trace("Could not open compare file 2\n");
        ret = FALSE;
    } else if(!ReadFile(handle1, buf1, sizeof(buf1), &bytes_read1, NULL)) {
        trace("Could not read compare file 1\n");
        ret = FALSE; 
    } else if(!ReadFile(handle2, buf2, sizeof(buf2), &bytes_read2, NULL)) {
        trace("Could not read compare file 2\n");
        ret = FALSE;
    } else if(bytes_read1 != bytes_read2) {
        trace("Number of bytes read do not match\n");
        ret = FALSE;
    } else if(memcmp(buf1, buf2, bytes_read1)) {
        trace("Bytes do not match\n");
        ret = FALSE;
    }

    if(handle1 != INVALID_HANDLE_VALUE) CloseHandle(handle1);
    if(handle2 != INVALID_HANDLE_VALUE) CloseHandle(handle2);
    return ret; 
}

static void test_GetPrivateProfileIntA( void )
{
    int i;
    UINT ret;

    struct param {
        char *lpAppName;
        char *lpKeyName;
        INT nDefault;
        char *lpFileName;
        UINT ret;
    };

    struct param params[] = {
    /* lpAppName       lpKeyName   nDefault   lpFileName       Ret */
      {NULL,           NULL,              1,  NULL,            0},
      {NULL,           NULL,              1,  "C:\\test.ini",  0},
      {NULL,           "Value",           1,  "C:\\test.ini",  0},
      {"No Keys",      NULL,              1,  "C:\\test.ini",  1},
      {"No Keys",      "Value",           1,  "C:\\test.ini",  1},     
      {"Values 1",     "NoValue",         1,  "C:\\test.ini",  1},
      {"VaLuEs 1",     "Value",           1,  "C:\\test.ini",  32767},
	  {"VaLuEs 1",     "Value",           1,  "test.ini",      1},
      {"VaLuEs 1",     "Value",           1,  "winetest.ini",  32767},
      {"Values 1",     "Comment",         1,  "C:\\test.ini",  1},
      {"Values 2",     "NoValue",         1,  "C:\\test.ini",  1},
      {"VALUES 2",     "Value",           1,  "C:\\test.ini",  -32768},
      {"Values 3",     "NoValue",         1,  "C:\\test.ini",  1},
      {"Values 3",     "Value",           1,  "C:\\test.ini",  32768},
      {"Values 4",     "NoValue",         1,  "C:\\test.ini",  1},
      {"Values 4",     "Value",           1,  "C:\\test.ini",  -32769},
      {"\"Strange\"",  "Value1",          1,  "C:\\test.ini",  1592593939},
      {"\"Strange\"",  "Value2",          1,  "C:\\test.ini",  0},
      {"\"Strange\"",  "Value3",          1,  "C:\\test.ini",  1},
      {"Duplicate",    "Value1",          1,  "C:\\test.ini",  7}
    };

    for(i = 0; i < sizeof(params) / sizeof(params[0]); i++) {
        ret = GetPrivateProfileIntA(params[i].lpAppName,
                                   params[i].lpKeyName, 
                                   params[i].nDefault,
                                   params[i].lpFileName);
        ok(ret == params[i].ret,
            "case %d: ret %u should be %u", i + 1, ret, params[i].ret);
    }             
}

static void test_GetPrivateProfileSectionA( void )
{
    unsigned i, j;
    DWORD ret;
    BOOL isError;
    char buf [1024];

    struct param {
        char *lpAppName;
        DWORD nSize;
        char *lpFileName;
        DWORD ret;
    };

    struct param params[] = {
    /* lpAppName       nSize,  lpFileName       Ret */
      {NULL,               0,  NULL,            0},
      {NULL,            1024,  NULL,            0},
      {NULL,            1024,  "C:\\test.ini",  0},
      {"No Keys",         -1,  "C:\\test.ini",  0},
      {"No Keys",          0,  "C:\\test.ini",  -1},
      {"No Keys",          1,  "C:\\test.ini",  -1},
      {"No Keys",          2,  "C:\\test.ini",  0},
      {"No Keys",       1024,  "C:\\test.ini",  0},
      {"Values 1",      1024,  "C:\\test.ini",  21},
      {"Values 1",      1024,  "winetest.ini",  21},
      {"\"Strange\"",   1024,  "C:\\test.ini",  76},
      {"Duplicate",       10,  "C:\\test.ini",  8}
    };

    char *lpReturnedString[] = {
        "test",
        "",
        "",
        "",
        "test",
        "",
        "",
        "",
		"NoValue=\0Value=32767",
        "NoValue=\0Value=32767",
        "Value1=112233445566778899\0Value1=-112233445566778899\0Value2=\" \\\"[Weird]\\\" \"",
        "Value1=7"
    };

    for(i = 0; i < sizeof(params) / sizeof(params[0]); i++) {
        isError = FALSE;
        strcpy(buf, "test");
        ret = GetPrivateProfileSectionA(params[i].lpAppName,
                                   buf, 
                                   params[i].nSize,
                                   params[i].lpFileName);

        ok(ret == params[i].ret, "case %d: ret %ld should be %ld", i + 1, 
                ret, params[i].ret);

        if(!ret || ret == -1) {
            ok(!strcmp(buf, lpReturnedString[i]),
              "case %d: '%s' should be '%s'", i + 1, buf, lpReturnedString[i]);
        } else {
            for(j = 0; j < ret; j++) {
                if(buf[j] != lpReturnedString[i][j]) {
                    ok(0, "case %d: return buffer does not match expected value", i + 1);
                    break;
                }
            }
            /* Make sure there is a double null terminator when needed */
            ok(params[i].lpAppName || !buf[j], 
                "case %d: missing double null termination", i + 1);
        }
    }

    /*
     * Special case: NULL lpReturnedString with size > 0
     * This causes an application error in win2k. Let's make wine better :)
     */
     ok(!GetPrivateProfileSectionA("No Keys", NULL, 1024, "C:\\test.ini"), 
             "special case not handled properly\n");
}

static void test_GetPrivateProfileSectionNamesA( void )
{
    unsigned i, j;
    DWORD ret;
    BOOL isError;
    char buf[1024];

    struct param {
        INT nSize;
        char *lpFileName;
        DWORD ret;
    };

    char *lpszReturnBuffer[] = {
        "test",
        "No Keys\0Values 1\0Values 2\0Values 3\0Values 4\0\"Strange\"\0Duplicate\0Duplicate\0Struct Section\0",
        "test",
        "",
        "",
        "No Keys\0Values 1\0Values 2\0Values 3\0Values 4\0\"Strange\"\0Duplicate\0Duplicate\0Struct Section\0",
        "No Keys\0Values 1\0Values 2\0Values 3\0Values 4\0\"Strange\"\0Duplicate\0Duplicate\0Struct Section\0",
        "",
    };

    struct param params[] = {
    /* nSize,  lpFileName         Ret */
      /* Test all null values */
      {0,      NULL,              0},
      
      /* Test with negative buffer size (large int) */
      {-1,     "C:\\test.ini",  89},
      
      /* Buffer size too small (0) */
      {0,      "C:\\test.ini",  0},
      
      /* Buffer size too small (1) */
      {1,      "C:\\test.ini",  0},
      
      /* Buffer size too small (2) */
      {2,      "C:\\test.ini",  0},
      
      /* Test normal operation */
      {1024,   "C:\\test.ini",  89},

      /* Test for file in windows directory */
      {1024,   "winetest.ini",    89},

      /* Test when file does not exist */
      {1024,   "test.ini",        0}
    };

    for(i = 0; i < sizeof(params) / sizeof(params[0]); i++) {
        isError = FALSE;
        strcpy(buf, "test");
        ret = GetPrivateProfileSectionNamesA(buf, params[i].nSize, 
                params[i].lpFileName);
        ok(ret == params[i].ret,
            "case %d: ret %ld should be %ld", i + 1, ret, params[i].ret);

        if(!ret) {
            ok(!strcmp(buf, lpszReturnBuffer[i]),
                "buffer '%s' should be '%s'", buf, lpszReturnBuffer[i]);
        } else {
            for(j = 0; j < ret; j++) {
                if(buf[j] != lpszReturnBuffer[i][j]) {
                    ok(0, "case %d: return buffer does not match expected value", i + 1);
                    break;
                }
            }
            /* Make sure there is a double null terminator */
            ok(!buf[j], "case %d: missing double null termination\n", i + 1);
         }
    }

    
    /* 
     * Special case: NULL lpReturnedString with size > 0
     * This causes an application error in win2k. Let's make wine better :)
     */
     ok(!GetPrivateProfileSectionNamesA(NULL, 1024, "C:\\test.ini"),
             "special case not handled");
}

static void test_GetPrivateProfileStringA( void )
{
    unsigned i, j;
    DWORD ret;
    BOOL isError;
    char buf [1024];

    struct param {
        char *lpAppName;
        char *lpKeyName;
        char *lpDefault;
        DWORD nSize;
        char *lpFileName;
        DWORD ret;
    };

    struct param params[] = {
/* #   lpAppName       lpKeyName    pDefault   nSize lpFileName         Ret */
/* 1: All null params */
      {NULL,           NULL,          NULL,      0,  NULL,              0},

/* 2: Default value with non-existent file */
      {NULL,           NULL,        "def ",    1024, "test.ini",        3},

/* 3: Buffer too small for section names (1) */
      {NULL,           NULL,         "def",       1, "C:\\test.ini",  0},

/* 4: Buffer too small for section names (2) */
      {NULL,           NULL,         "def",       2, "C:\\test.ini",  0},

/* 5: Buffer too small for section names (3) */
      {NULL,           NULL,         "def",       3, "C:\\test.ini",  1},

/* 6: Section names */
      {NULL,           NULL,         "def",    1024, "C:\\test.ini",  89},

/* 7: Buffer too small for keys (1) */
      {"No Keys",      NULL,         "def",       1, "C:\\test.ini",  -1},

/* 8: Buffer too small for keys (2) */
      {"No Keys",      NULL,         "def",       2, "C:\\test.ini",  0},

/* 9: Buffer too small for keys (3) */
      {"No Keys",      NULL,         "def",       2, "C:\\test.ini",  0},

/* 10: Keys  */
      {"Values 1",     NULL,         "def",    1024, "C:\\test.ini",  14},

/* 11: Comments */
      {"Values 1",     "Comment",    "def",    1024, "C:\\test.ini",  3},

/* 12 */
      {"Values 1",     "NoValue",    "",       1024, "C:\\test.ini",  0},

/* 13 */
      {"VaLuEs 1",     "Value",      "def",    1024, "C:\\test.ini",  5},

/* 14: Make sure files in current directory are not opened */
      {"VaLuEs 1",     "Value",      "def",    1024, "test.ini",        3},

/* 15: Make sure files in windows directory are opened */
      {"VaLuEs 1",     "Value",      "def",    1024, "winetest.ini",    5},

/* 16 - 25: Test various values */
      {"Values 2",     "NoValue",    " ",      1024, "C:\\test.ini",  0},

/* 17 */
      {"VALUES 2",     "Value",      "def",    1024, "C:\\test.ini",  6},

/* 18 */
      {"Values 3",     "NoValue",    "def ",   1024, "C:\\test.ini",  0},

/* 19 */
      {"Values 3",     "Value",      "def",    1024, "C:\\test.ini",  5},

/* 20 */
      {"Values 4",     "NoValue",    " def",   1024, "C:\\test.ini",  0},

/* 21 */
      {"Values 4",     "Value",      "def",    1024, "C:\\test.ini",  6},

/* 22 */
      {"\"Strange\"",  "Value1",     "def",    1024, "C:\\test.ini",  18},

/* 23 */
      {"\"Strange\"",  "Value2",     "def",    1024, "C:\\test.ini",  13},

/* 24 */
      {"\"Strange\"",  "Value3",     "def",    1024, "C:\\test.ini",   3},

/* 25 */
      {"Duplicate",    "Value1",     "def",    1024, "C:\\test.ini",   1}
    };

    char *lpReturnedString[] = {
        "test",
        "def",
        "",
        "",
        "N",
        "No Keys\0Values 1\0Values 2\0Values 3\0Values 4\0\"Strange\"\0Duplicate\0Duplicate\0Struct Section\0",
        "",
        "",
        "",
        "NoValue\0Value\0",
        "def",
        "",
        "32767",
		"def",
        "32767",
		"",
        "-32768",
        "",
        "32768",
        "",
        "-32769",
        "112233445566778899",
        " \\\"[Weird]\\\" ",
        "def",
        "7"
    };


    for(i = 0; i < sizeof(params) / sizeof(params[0]); i++) {
        isError = FALSE;
        strcpy(buf, "test");
        ret = GetPrivateProfileStringA(params[i].lpAppName,
                                      params[i].lpKeyName,
                                      params[i].lpDefault,
                                      buf,
                                      params[i].nSize,
                                      params[i].lpFileName);

        ok(ret == params[i].ret, 
            "case %d: ret %ld should be %ld\n", i + 1, ret, params[i].ret);

        if(!ret || ret == -1) {
            ok(!strcmp(buf, lpReturnedString[i]),
                "buffer '%s' should be '%s'\n", buf, lpReturnedString[i]); 
        } else {
            for(j = 0; j < ret; j++) {
                if(buf[j] != lpReturnedString[i][j]) {
                    ok(0, "case %d: return buffer does not match expected value", i + 1);
                    break;
                }
            }
            /* Make sure there is a double null terminator when needed */
            ok((params[i].lpAppName && params[i].lpKeyName) || !buf[j], 
                "case %d: missing double null termination", i + 1);
        }
    }
	
    /* Get section names of win.ini */
    ret = GetPrivateProfileStringA(NULL, NULL, NULL, buf, 1024, NULL);
    ok(ret > 3, "error opening win.ini");
}

static void test_GetPrivateProfileStructA( void )
{
    struct test {
        char str[5];
        int number;
        double pi;
    } orig = {"Josh", 7, 3.14}, test;

    
    ok(GetPrivateProfileStructA("Struct Section", "Struct Key", &test, 
                sizeof(struct test), "C:\\test.ini"),
        "GetPrivateProfileStructA failed");

    ok(!strcmp(orig.str, test.str)
            && test.number == orig.number
            && test.pi == orig.pi, 
        "returned struct values do not match expected values");
}

static void test_WritePrivateProfileSectionA( void )
{
    int i;
    DWORD error;
    BOOL ret, isError;
    HANDLE handle;
    char filename[1024];
    
    struct param {
        char *lpAppName;
        char *lpString;
        char *lpFileName;
        BOOL ret;
        DWORD error;
    };

    struct param params[] = {
/* # lpAppName      lpString     lpFileName         Ret  Error */
/* 1: Null parameters. */
      {NULL,          NULL,      NULL,               1, 0},

/* 2: Test if win.ini is written to */
      {"Wine Test",   "Value=1\0", NULL,             1, 0},

/* 3: Test if windows directory is used (and file is created) */
      {"Wine Test",   "Value=1\0", "winetest.ini",   1, 0},

/* 4: Test what happens when lpAppName is null */
      {NULL,          "Test\0",    "C:\\result.ini", 0, 2},

/* 5: Test what happens when lpString is null. */
      {"Null",        NULL,        "C:\\result.ini", 1, 0},

/* 6: Test section with no keys. */ 
      {"No Keys",     " ",         "C:\\result.ini", 1, 0},

/* 7: Test key with no value */
      {"No Values 2", "Value=\0",  "C:\\result.ini", 1, 0},

/* 8: Test overwrite of key */
      {"Duplicate",
       "Value1=112233445566778899\0Value1=-112233445566778899\0Value2=\" \\\"[Weird]\\\" \"\0",  
                                   "C:\\result.ini", 1, 0},

/* 9: Test what happens when absolute path file does not exist.
 *    (MSDN docs are wrong. The file should be created) 
 */
      {"Wine Test",   "Value=1\0", "C:\\winetest.ini", 1, 2},

/* 10 - 11: Interesting obscure behaviour here... should this be tested? */
      {"[Strange 2]", "Value=1\0", "C:\\result.ini", 1, 0},
      {"[Strange 2]", "Value=2\0", "C:\\result.ini", 1, 0},
    };

    for(i = 0; i < sizeof(params) / sizeof(params[0]); i++) {
        isError = FALSE;
        ret = WritePrivateProfileSectionA(params[i].lpAppName,
                                         params[i].lpString,
                                         params[i].lpFileName);
        ok(ret == params[i].ret, 
                "case %d: ret %d should be %d", i + 1, ret, params[i].ret);
        if(!ret) {
            error = GetLastError();
            ok(error == params[i].error, 
                "case %d: GetLastError should return %ld; not %ld", i + 1,
                params[i].error, error);
        }
    }

    sprintf(filename, "%s\\winetest.ini", winpath);
    handle = CreateFileA( filename, 0, 0, NULL, OPEN_EXISTING, 
            FILE_ATTRIBUTE_NORMAL, 0);
    if(handle == INVALID_HANDLE_VALUE) {
        ok(0, "%s was not created", filename);
    } else {
        CloseHandle(handle);
        DeleteFileA(filename);
    }

    sprintf(filename, "c:\\winetest.ini");
    handle = CreateFileA( filename, 0, 0, NULL, OPEN_EXISTING, 
            FILE_ATTRIBUTE_NORMAL, 0);
    ok(handle != INVALID_HANDLE_VALUE, "%s was not created", filename);
    CloseHandle(handle);
    DeleteFileA(filename);

    ok(SearchPathA(NULL, "compare1.ini", NULL, sizeof(filename), filename, NULL), "could not find compare1.ini");
    ok(compare(filename, "C:\\result.ini"),
        "c:\\result.ini does not match compare1.ini");
    DeleteFileA("C:\\result.ini");
}

static void test_WritePrivateProfileStringA( void )
{
    int i;
    BOOL ret;
    DWORD error;
    HANDLE handle;
    char filename[1024];

  
    struct param {
        char *lpAppName;
        char *lpKeyName;
        char *lpString;
        char *lpFileName;
        BOOL ret;
        DWORD error;
    };

    struct param params[] = {
/* # lpAppName         lpKeyName, lpString     lpFileName          Ret  Error */
/* 1  Null parameters. I guess windows lies about the return value */
      {NULL,           NULL,       NULL,       NULL,                1, 0},

/* 2  Test if win.ini is written to and entry is deleted */
      {"Wine Test",    NULL,       NULL,       NULL,                1, 0},

/* 3  Test if windows directory is used and file is created */
      {"Wine Test",    "Value1",   "1",        "winetest.ini",      1, 0},

/* 4  Test what happens when lpAppName is null */
      {NULL,           "Value2",   "2",         "C:\\result.ini", 0, 2},

/* 5  Test what happens when section is not found */
      {"Null",         "Key",      "Value",     "C:\\result.ini", 1, 0},

/* 5  Test what happens when key is not found */
      {"Values 1",     "Null",     "Value",     "C:\\result.ini", 1, 0},

/* 6  Test section with no keys. */ 
      {"No Keys",      "",         "3",         "C:\\result.ini", 1, 0},

/* 7  Test deletion of value */
      {"Values 1",     "Value",    NULL,        "C:\\result.ini", 1, 0},

/* 8: Test deletion of value */
      {"Values 2",     "Value",    "",          "C:\\result.ini", 1, 0},

/* 9: Test overwrite of value */
      {"Duplicate",    "Value1",   " Replaced", "C:\\result.ini", 1, 0},

/* 10 Test key deletion */
      {"\"Strange\"",  NULL,       "Replace",   "C:\\result.ini", 1, 0},
       
/* 11 Test what happens when absolute path file does not exist
 *    (File should be created) */
      {"Wine Test",   "Test",      "1",         "C:\\winetest.ini", 1, 0},
    };

    ok(CopyFileA("c:\\test.ini", "c:\\result.ini", FALSE),
        "could not copy c:\\test.ini to c:\\result.ini, err=%ld",
        GetLastError());

    for(i = 0; i < sizeof(params) / sizeof(params[0]); i++) {
        ret = WritePrivateProfileStringA(params[i].lpAppName,
                                        params[i].lpKeyName,
                                        params[i].lpString,
                                        params[i].lpFileName);
        ok(ret == params[i].ret, "case %d: ret %d should be %d", i + 1,
                ret, params[i].ret);

        if(!ret) {
            error = GetLastError();
            ok(error == params[i].error, 
              "case %d: GetLastError should return %ld; not %ld", ret + 1, 
              params[i].error, error);
        }
    }

    /* See if the Wine Test key was deleted in win.ini */
    ok(!GetPrivateProfileIntA("Wine Test", "Value", 0, NULL),
        "Wine Test key was not deleted from win.ini");

    /* See if the INI file was created in the windows directory */
    sprintf(filename, "%s\\winetest.ini", winpath);
    handle = CreateFileA( filename, 0, 0, NULL, OPEN_EXISTING, 
            FILE_ATTRIBUTE_NORMAL, 0);
    ok(handle != INVALID_HANDLE_VALUE, "%s was not created", filename);
    CloseHandle(handle);
    DeleteFileA(filename);

    /* See if the INI file with an absolute path was created */
    sprintf(filename, "c:\\winetest.ini");
    handle = CreateFileA( filename, 0, 0, NULL, OPEN_EXISTING, 
            FILE_ATTRIBUTE_NORMAL, 0);
    ok(handle != INVALID_HANDLE_VALUE, "%s was not created", filename);
    CloseHandle(handle);
    sprintf(filename, "%s", filename);
    DeleteFileA(filename);

    ok(SearchPathA(NULL, "compare2.ini", NULL, sizeof(filename), filename, NULL), "could not find compare2.ini");
    ok(compare(filename, "C:\\result.ini"),
       "c:\\result.ini does not match compare2.ini");

    DeleteFileA("C:\\result.ini");
}

static void test_WritePrivateProfileStructA( void )
{
    struct test {
        char str[5];
        int number;
        double e;
    } orig = {"Test", 0x7FFFFFFF, 2.718281828459 }, test;
    
    ok(WritePrivateProfileStructA("Struct Test", "Struct Key", &orig, 
                sizeof(struct test), "C:\\result.ini"),
        "[Struct Test] key was not created");

    ok(GetPrivateProfileStructA("Struct Test", "Struct Key", &test, 
                sizeof(struct test), "C:\\result.ini"),
        "key, [Struct Test], was not found");

    ok(!strcmp(orig.str, test.str)
            && test.number == orig.number
            && test.e == orig.e, 
        "returned struct values do not match expected values");

    DeleteFileA("C:\\result.ini");
}

START_TEST(profile)
{
	char testname[1024], filename[1024];

	GetWindowsDirectoryA(winpath, sizeof(filename));

    /* Back up win.ini (just in case) */
    sprintf(filename, "%s\\win.ini", winpath);
    ok(CopyFileA(filename, "win.ini", FALSE),
       "could back up win.ini to current directory (err=%ld)", GetLastError());

    /* Copy test.ini to c:\ */
    ok(SearchPathA(NULL, "test.ini", NULL, sizeof(testname), testname, NULL),
            "could not find test.ini");
    ok(CopyFileA(testname, "C:\\test.ini", FALSE),
       "could not copy test.ini to C:\\test.ini (err=%ld)", GetLastError());

     /* Copy test.ini to windows directory as winetest.ini */
    sprintf(filename, "%s\\winetest.ini", winpath);
    ok(CopyFileA(testname, filename, FALSE),
       "could not copy test.ini to %s (err=%ld)", filename, GetLastError());

    test_GetPrivateProfileIntA();
    test_GetPrivateProfileSectionA();
    test_GetPrivateProfileSectionNamesA();
    test_GetPrivateProfileStringA();
    test_GetPrivateProfileStructA();

    DeleteFileA(filename);
    test_WritePrivateProfileSectionA();
    test_WritePrivateProfileStringA();
    test_WritePrivateProfileStructA();

    /* Restore win.ini */
    sprintf(filename, "%s\\win.ini", winpath);
    CopyFileA("win.ini", filename, FALSE);
    DeleteFileA("win.ini");
    
    sprintf(filename, "%s\\winetest.ini", winpath);
    DeleteFileA("C:\\winetest.ini");

    DeleteFileA("c:\\test.ini");
}

;INI file to test GetProfile functions


[No Keys]
;

[Values 1]
;Comment=1
NoValue=
Value=32767

[Values 2]
NoValue=""
Value="-32768"

[Values 3]
NoValue = 
Value = 32768

[Values 4]
NoValue = ""
Value = "-32769"

["Strange"]
; Testing
Value1 = 112233445566778899
Value1 = -112233445566778899
Value2 = " \"[Weird]\" "

[Duplicate]
Value1 = 7

 ; Comment = "3"
[Duplicate]
Value1 = 10

[Struct Section]
Struct Key=4A6F73680000000007000000089241001F85EB51B81E094075

;Comment 4



; INI file used to test WritePrivateProfile functions
[No Keys]
 
[No Values 2]
Value=
[Duplicate]
Value1=112233445566778899
Value1=-112233445566778899
Value2=" \"[Weird]\" "
[[Strange 2]]
Value=1
[[Strange 2]]
Value=2
;INI file to test WritePrivateProfile functions


[No Keys]
=3
;

[Values 1]
;Comment=1
NoValue=
Null=Value

[Values 2]
NoValue=""
Value=

[Values 3]
NoValue = 
Value = 32768

[Values 4]
NoValue = ""
Value = "-32769"


[Duplicate]
Value1 = Replaced

 ; Comment = "3"
[Duplicate]
Value1 = 10

[Struct Section]
Struct Key=4A6F73680000000007000000089241001F85EB51B81E094075

;Comment 4



[Null]
Key=Value
Index: wine/dlls/kernel/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/kernel/Makefile.in,v
retrieving revision 1.37
diff -u -r1.37 Makefile.in
--- wine/dlls/kernel/Makefile.in	14 Jun 2002 02:09:08 -0000	1.37
+++ wine/dlls/kernel/Makefile.in	2 Jul 2002 04:00:42 -0000
@@ -46,6 +46,7 @@
 	tests/locale.c \
 	tests/path.c \
 	tests/process.c \
+	tests/profile.c \
 	tests/thread.c
 
 PLTESTS = \

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux