31
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#include "test-utils.h"
|
|
21 |
#include <unistd.h>
|
|
22 |
int write_to_configfile()
|
|
23 |
{
|
|
24 |
FILE *fp;
|
|
25 |
char buff[10];
|
|
26 |
fp = fopen("c:\\data\\dbus\\system.conf", "r+");
|
|
27 |
if(fp)
|
|
28 |
{
|
|
29 |
fread(buff,1,10,fp);
|
|
30 |
fwrite(buff,1,10,fp);
|
|
31 |
fclose(fp);
|
|
32 |
return 0;
|
|
33 |
}
|
|
34 |
return 1;
|
|
35 |
}
|
|
36 |
|
|
37 |
int reset_case_passed()
|
|
38 |
{
|
|
39 |
FILE *fp;
|
|
40 |
fp = fopen("C:\\data\\dbus\\test_result.txt","w+");
|
|
41 |
if(fp)
|
|
42 |
{
|
|
43 |
//we simply create empty file
|
|
44 |
fclose(fp);
|
|
45 |
}
|
|
46 |
}
|
|
47 |
int check_case_passed()
|
|
48 |
{
|
|
49 |
FILE *fp;
|
|
50 |
char buf[50];
|
|
51 |
int n;
|
|
52 |
fp = fopen("C:\\data\\dbus\\test_result.txt","r");
|
|
53 |
if(fp)
|
|
54 |
{
|
|
55 |
n = fread(buf,1,30,fp);
|
|
56 |
if(n>0)
|
|
57 |
{
|
|
58 |
//case passed
|
|
59 |
fclose(fp);
|
|
60 |
return 0;
|
|
61 |
}
|
|
62 |
|
|
63 |
}
|
|
64 |
return 1;
|
|
65 |
}
|
|
66 |
int
|
|
67 |
main ()
|
|
68 |
{
|
|
69 |
DBusError error;
|
|
70 |
DBusConnection *connection;
|
|
71 |
|
|
72 |
|
|
73 |
dbus_error_init (&error);
|
|
74 |
connection = dbus_bus_get (DBUS_BUS_SESSION, &error);
|
|
75 |
if (connection == NULL)
|
|
76 |
{
|
|
77 |
fprintf (stderr, "*** Failed to open connection to system bus: %s\n",
|
|
78 |
error.message);
|
|
79 |
dbus_error_free (&error);
|
|
80 |
getchar();
|
|
81 |
return 1;
|
|
82 |
}
|
|
83 |
if(!reset_case_passed())
|
|
84 |
{
|
|
85 |
write_to_configfile();
|
|
86 |
|
|
87 |
}
|
|
88 |
sleep(10);
|
|
89 |
return check_case_passed();
|
|
90 |
|
|
91 |
}
|