diff options
Diffstat (limited to 'linden/indra/test/llmessageconfig_tut.cpp')
-rw-r--r-- | linden/indra/test/llmessageconfig_tut.cpp | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/linden/indra/test/llmessageconfig_tut.cpp b/linden/indra/test/llmessageconfig_tut.cpp index cc2a0a2..df50d90 100644 --- a/linden/indra/test/llmessageconfig_tut.cpp +++ b/linden/indra/test/llmessageconfig_tut.cpp | |||
@@ -3,6 +3,8 @@ | |||
3 | * @date March 2007 | 3 | * @date March 2007 |
4 | * @brief LLMessageConfig unit tests | 4 | * @brief LLMessageConfig unit tests |
5 | * | 5 | * |
6 | * $LicenseInfo:firstyear=2006&license=viewergpl$ | ||
7 | * | ||
6 | * Copyright (c) 2006-2007, Linden Research, Inc. | 8 | * Copyright (c) 2006-2007, Linden Research, Inc. |
7 | * | 9 | * |
8 | * Second Life Viewer Source Code | 10 | * Second Life Viewer Source Code |
@@ -25,16 +27,18 @@ | |||
25 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | 27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO |
26 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | 28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, |
27 | * COMPLETENESS OR PERFORMANCE. | 29 | * COMPLETENESS OR PERFORMANCE. |
30 | * $/LicenseInfo$ | ||
28 | */ | 31 | */ |
29 | 32 | ||
30 | #include <tut/tut.h> | 33 | #include "linden_common.h" |
31 | #include "lltut.h" | ||
32 | #include "llmessageconfig.h" | 34 | #include "llmessageconfig.h" |
35 | #include "lltut.h" | ||
33 | #include "llsdserialize.h" | 36 | #include "llsdserialize.h" |
34 | #include "llfile.h" | 37 | #include "llfile.h" |
35 | #include "lldir.h" | 38 | #include "lldir.h" |
36 | #include "lltimer.h" | 39 | #include "lltimer.h" |
37 | #include "llframetimer.h" | 40 | #include "llframetimer.h" |
41 | #include "llsdutil.h" | ||
38 | 42 | ||
39 | namespace tut | 43 | namespace tut |
40 | { | 44 | { |
@@ -43,30 +47,30 @@ namespace tut | |||
43 | 47 | ||
44 | LLMessageConfigTestData() | 48 | LLMessageConfigTestData() |
45 | { | 49 | { |
50 | LLUUID random; | ||
51 | random.generate(); | ||
46 | // generate temp dir | 52 | // generate temp dir |
47 | mTestConfigDir = "/tmp/llmessage-config-test"; | 53 | std::ostringstream oStr; |
54 | oStr << "/tmp/llmessage-config-test-" << random; | ||
55 | mTestConfigDir = oStr.str(); | ||
48 | LLFile::mkdir(mTestConfigDir.c_str()); | 56 | LLFile::mkdir(mTestConfigDir.c_str()); |
49 | 57 | writeConfigFile(LLSD()); | |
50 | LLMessageConfig::initClass("simulator", mTestConfigDir); | 58 | LLMessageConfig::initClass("simulator", mTestConfigDir); |
51 | } | 59 | } |
52 | 60 | ||
53 | ~LLMessageConfigTestData() | 61 | ~LLMessageConfigTestData() |
54 | { | 62 | { |
55 | // rm contents of temp dir | 63 | // rm contents of temp dir |
56 | gDirUtilp->deleteFilesInDir(mTestConfigDir, "*"); | 64 | int rmfile = LLFile::remove((mTestConfigDir + "/message.xml").c_str()); |
65 | ensure_equals("rmfile value", rmfile, 0); | ||
57 | // rm temp dir | 66 | // rm temp dir |
58 | LLFile::rmdir(mTestConfigDir.c_str()); | 67 | int rmdir = LLFile::rmdir(mTestConfigDir.c_str()); |
68 | ensure_equals("rmdir value", rmdir, 0); | ||
59 | } | 69 | } |
60 | 70 | ||
61 | void reloadConfig(const LLSD& config) | ||
62 | { | ||
63 | LLMessageConfig::useConfig(config); | ||
64 | } | ||
65 | |||
66 | void writeConfigFile(const LLSD& config) | 71 | void writeConfigFile(const LLSD& config) |
67 | { | 72 | { |
68 | std::string configFile = mTestConfigDir + "/message.xml"; | 73 | llofstream file((mTestConfigDir + "/message.xml").c_str()); |
69 | llofstream file(configFile.c_str()); | ||
70 | if (file.is_open()) | 74 | if (file.is_open()) |
71 | { | 75 | { |
72 | LLSDSerialize::toPrettyXML(config, file); | 76 | LLSDSerialize::toPrettyXML(config, file); |
@@ -85,7 +89,7 @@ namespace tut | |||
85 | { | 89 | { |
86 | LLSD config; | 90 | LLSD config; |
87 | config["serverDefaults"]["simulator"] = "template"; | 91 | config["serverDefaults"]["simulator"] = "template"; |
88 | reloadConfig(config); | 92 | LLMessageConfig::useConfig(config); |
89 | ensure_equals("Ensure server default is not template", | 93 | ensure_equals("Ensure server default is not template", |
90 | LLMessageConfig::getServerDefaultFlavor(), | 94 | LLMessageConfig::getServerDefaultFlavor(), |
91 | LLMessageConfig::TEMPLATE_FLAVOR); | 95 | LLMessageConfig::TEMPLATE_FLAVOR); |
@@ -99,7 +103,7 @@ namespace tut | |||
99 | config["serverDefaults"]["simulator"] = "template"; | 103 | config["serverDefaults"]["simulator"] = "template"; |
100 | config["messages"]["msg1"]["flavor"] = "template"; | 104 | config["messages"]["msg1"]["flavor"] = "template"; |
101 | config["messages"]["msg2"]["flavor"] = "llsd"; | 105 | config["messages"]["msg2"]["flavor"] = "llsd"; |
102 | reloadConfig(config); | 106 | LLMessageConfig::useConfig(config); |
103 | ensure_equals("Ensure msg template flavor", | 107 | ensure_equals("Ensure msg template flavor", |
104 | LLMessageConfig::getMessageFlavor("msg1"), | 108 | LLMessageConfig::getMessageFlavor("msg1"), |
105 | LLMessageConfig::TEMPLATE_FLAVOR); | 109 | LLMessageConfig::TEMPLATE_FLAVOR); |
@@ -115,7 +119,7 @@ namespace tut | |||
115 | LLSD config; | 119 | LLSD config; |
116 | config["serverDefaults"]["simulator"] = "llsd"; | 120 | config["serverDefaults"]["simulator"] = "llsd"; |
117 | config["messages"]["msg1"]["trusted-sender"] = true; | 121 | config["messages"]["msg1"]["trusted-sender"] = true; |
118 | reloadConfig(config); | 122 | LLMessageConfig::useConfig(config); |
119 | ensure_equals("Ensure missing message gives no flavor", | 123 | ensure_equals("Ensure missing message gives no flavor", |
120 | LLMessageConfig::getMessageFlavor("Test"), | 124 | LLMessageConfig::getMessageFlavor("Test"), |
121 | LLMessageConfig::NO_FLAVOR); | 125 | LLMessageConfig::NO_FLAVOR); |
@@ -137,7 +141,7 @@ namespace tut | |||
137 | config["messages"]["msg1"]["trusted-sender"] = false; | 141 | config["messages"]["msg1"]["trusted-sender"] = false; |
138 | config["messages"]["msg2"]["flavor"] = "llsd"; | 142 | config["messages"]["msg2"]["flavor"] = "llsd"; |
139 | config["messages"]["msg2"]["trusted-sender"] = true; | 143 | config["messages"]["msg2"]["trusted-sender"] = true; |
140 | reloadConfig(config); | 144 | LLMessageConfig::useConfig(config); |
141 | ensure_equals("Ensure untrusted is untrusted", | 145 | ensure_equals("Ensure untrusted is untrusted", |
142 | LLMessageConfig::getSenderTrustedness("msg1"), | 146 | LLMessageConfig::getSenderTrustedness("msg1"), |
143 | LLMessageConfig::UNTRUSTED); | 147 | LLMessageConfig::UNTRUSTED); |
@@ -156,7 +160,7 @@ namespace tut | |||
156 | LLSD config; | 160 | LLSD config; |
157 | config["serverDefaults"]["simulator"] = "template"; | 161 | config["serverDefaults"]["simulator"] = "template"; |
158 | config["messages"]["msg1"]["flavor"] = "llsd"; | 162 | config["messages"]["msg1"]["flavor"] = "llsd"; |
159 | reloadConfig(config); | 163 | LLMessageConfig::useConfig(config); |
160 | ensure_equals("Ensure msg1 exists, has llsd flavor", | 164 | ensure_equals("Ensure msg1 exists, has llsd flavor", |
161 | LLMessageConfig::getMessageFlavor("msg1"), | 165 | LLMessageConfig::getMessageFlavor("msg1"), |
162 | LLMessageConfig::LLSD_FLAVOR); | 166 | LLMessageConfig::LLSD_FLAVOR); |
@@ -171,7 +175,7 @@ namespace tut | |||
171 | LLSD config; | 175 | LLSD config; |
172 | config["capBans"]["MapLayer"] = true; | 176 | config["capBans"]["MapLayer"] = true; |
173 | config["capBans"]["MapLayerGod"] = false; | 177 | config["capBans"]["MapLayerGod"] = false; |
174 | reloadConfig(config); | 178 | LLMessageConfig::useConfig(config); |
175 | ensure_equals("Ensure cap ban true MapLayer", | 179 | ensure_equals("Ensure cap ban true MapLayer", |
176 | LLMessageConfig::isCapBanned("MapLayer"), | 180 | LLMessageConfig::isCapBanned("MapLayer"), |
177 | true); | 181 | true); |