diff options
Diffstat (limited to 'linden/indra/test/message_tut.cpp')
-rw-r--r-- | linden/indra/test/message_tut.cpp | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/linden/indra/test/message_tut.cpp b/linden/indra/test/message_tut.cpp index b619d38..f3325f0 100644 --- a/linden/indra/test/message_tut.cpp +++ b/linden/indra/test/message_tut.cpp | |||
@@ -35,6 +35,8 @@ | |||
35 | #include "lltut.h" | 35 | #include "lltut.h" |
36 | 36 | ||
37 | #include "llapr.h" | 37 | #include "llapr.h" |
38 | #include "llmessageconfig.h" | ||
39 | #include "llsdserialize.h" | ||
38 | #include "llversionserver.h" | 40 | #include "llversionserver.h" |
39 | #include "message.h" | 41 | #include "message.h" |
40 | #include "message_prehash.h" | 42 | #include "message_prehash.h" |
@@ -56,10 +58,13 @@ namespace tut | |||
56 | { | 58 | { |
57 | struct LLMessageSystemTestData | 59 | struct LLMessageSystemTestData |
58 | { | 60 | { |
61 | std::string mTestConfigDir; | ||
62 | std::string mSep; | ||
63 | |||
59 | LLMessageSystemTestData() | 64 | LLMessageSystemTestData() |
60 | { | 65 | { |
61 | static bool init = false; | 66 | static bool init = false; |
62 | if(! init) | 67 | if(!init) |
63 | { | 68 | { |
64 | ll_init_apr(); | 69 | ll_init_apr(); |
65 | //init_prehash_data(); | 70 | //init_prehash_data(); |
@@ -72,7 +77,25 @@ namespace tut | |||
72 | LL_VERSION_MINOR, | 77 | LL_VERSION_MINOR, |
73 | LL_VERSION_PATCH, | 78 | LL_VERSION_PATCH, |
74 | FALSE, | 79 | FALSE, |
75 | "notasharedsecret"); | 80 | "notasharedsecret", |
81 | NULL, | ||
82 | false); | ||
83 | // generate temp dir | ||
84 | std::ostringstream ostr; | ||
85 | #if LL_WINDOWS | ||
86 | mSep = "\\"; | ||
87 | ostr << "C:" << mSep; | ||
88 | #else | ||
89 | mSep = "/"; | ||
90 | ostr << mSep << "tmp" << mSep; | ||
91 | #endif | ||
92 | LLUUID random; | ||
93 | random.generate(); | ||
94 | ostr << "message-test-" << random; | ||
95 | mTestConfigDir = ostr.str(); | ||
96 | LLFile::mkdir(mTestConfigDir); | ||
97 | writeConfigFile(LLSD()); | ||
98 | LLMessageConfig::initClass("simulator", ostr.str()); | ||
76 | } | 99 | } |
77 | 100 | ||
78 | ~LLMessageSystemTestData() | 101 | ~LLMessageSystemTestData() |
@@ -80,6 +103,28 @@ namespace tut | |||
80 | // not end_messaging_system() | 103 | // not end_messaging_system() |
81 | delete gMessageSystem; | 104 | delete gMessageSystem; |
82 | gMessageSystem = NULL; | 105 | gMessageSystem = NULL; |
106 | |||
107 | // rm contents of temp dir | ||
108 | std::ostringstream ostr; | ||
109 | ostr << mTestConfigDir << mSep << "message.xml"; | ||
110 | int rmfile = LLFile::remove(ostr.str()); | ||
111 | ensure_equals("rmfile value", rmfile, 0); | ||
112 | |||
113 | // rm temp dir | ||
114 | int rmdir = LLFile::rmdir(mTestConfigDir); | ||
115 | ensure_equals("rmdir value", rmdir, 0); | ||
116 | } | ||
117 | |||
118 | void writeConfigFile(const LLSD& config) | ||
119 | { | ||
120 | std::ostringstream ostr; | ||
121 | ostr << mTestConfigDir << mSep << "message.xml"; | ||
122 | llofstream file(ostr.str()); | ||
123 | if (file.is_open()) | ||
124 | { | ||
125 | LLSDSerialize::toPrettyXML(config, file); | ||
126 | } | ||
127 | file.close(); | ||
83 | } | 128 | } |
84 | }; | 129 | }; |
85 | 130 | ||