Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifdef IOS
21 : #define CPPUNIT_PLUGIN_EXPORTED_NAME cppunitTest_osl_process
22 : #endif
23 :
24 : #include <sal/types.h>
25 : #include <cppunit/TestFixture.h>
26 : #include <cppunit/extensions/HelperMacros.h>
27 : #include <cppunit/plugin/TestPlugIn.h>
28 :
29 : #define t_print printf
30 :
31 : #include <osl/process.h>
32 : #include <osl/file.hxx>
33 : #include <osl/thread.h>
34 : #include <rtl/ustring.hxx>
35 : #include <unistd.h>
36 : #include <signal.h>
37 :
38 : #include <stdio.h>
39 : #include <stdlib.h>
40 : #include <osl/module.hxx>
41 : #include <sal/macros.h>
42 :
43 : #if ( defined WNT ) // Windows
44 : # include <windows.h>
45 : # include <tchar.h>
46 : #endif
47 :
48 : #include "rtl/allocator.hxx"
49 :
50 : #include <iostream>
51 : #include <fstream>
52 : #include <vector>
53 : #include <algorithm>
54 : #include <iterator>
55 : #include <string>
56 :
57 : #ifdef UNX
58 : #if defined( MACOSX )
59 : # include <crt_externs.h>
60 : # define environ (*_NSGetEnviron())
61 : # else
62 : extern char** environ;
63 : # endif
64 : #endif
65 :
66 : #if defined(WNT)
67 : const rtl::OUString EXECUTABLE_NAME ("osl_process_child.exe");
68 : #else
69 1 : const rtl::OUString EXECUTABLE_NAME ("osl_process_child");
70 : #endif
71 :
72 : //########################################
73 : using namespace osl;
74 :
75 : using ::rtl::OUString;
76 : using ::rtl::OUStringToOString;
77 : using ::rtl::OString;
78 :
79 : /** print a UNI_CODE String.
80 : */
81 : inline void printUString( const ::rtl::OUString & str )
82 : {
83 : rtl::OString aString;
84 :
85 : t_print("#printUString_u# " );
86 : aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US );
87 : t_print("%s\n", aString.getStr( ) );
88 : }
89 :
90 : /** get binary Path.
91 : */
92 3 : inline ::rtl::OUString getExecutablePath( void )
93 : {
94 3 : ::rtl::OUString dirPath;
95 3 : osl::Module::getUrlFromAddress( ( void* ) &getExecutablePath, dirPath );
96 3 : dirPath = dirPath.copy( 0, dirPath.lastIndexOf('/') );
97 3 : dirPath = dirPath.copy( 0, dirPath.lastIndexOf('/') + 1);
98 3 : dirPath += rtl::OUString("Executable");
99 3 : return dirPath;
100 : }
101 :
102 : //rtl::OUString CWD = getExecutablePath();
103 :
104 : //########################################
105 0 : class Test_osl_joinProcess : public CppUnit::TestFixture
106 : {
107 : const OUString join_param_;
108 : const OUString wait_time_;
109 : OUString suCWD;
110 : OUString suExecutableFileURL;
111 :
112 : rtl_uString* parameters_[2];
113 : int parameters_count_;
114 :
115 : public:
116 :
117 0 : Test_osl_joinProcess() :
118 : join_param_(OUString("-join")),
119 : wait_time_(OUString("1")),
120 0 : parameters_count_(2)
121 : {
122 0 : parameters_[0] = join_param_.pData;
123 0 : parameters_[1] = wait_time_.pData;
124 0 : suCWD = getExecutablePath();
125 0 : suExecutableFileURL = suCWD;
126 0 : suExecutableFileURL += rtl::OUString("/");
127 0 : suExecutableFileURL += EXECUTABLE_NAME;
128 0 : }
129 :
130 : /*-------------------------------------
131 : Start a process and join with this
132 : process specify a timeout so that
133 : osl_joinProcessWithTimeout returns
134 : osl_Process_E_TimedOut
135 : -------------------------------------*/
136 :
137 : void osl_joinProcessWithTimeout_timeout_failure()
138 : {
139 : oslProcess process;
140 : oslProcessError osl_error = osl_executeProcess(
141 : suExecutableFileURL.pData,
142 : parameters_,
143 : parameters_count_,
144 : osl_Process_NORMAL,
145 : osl_getCurrentSecurity(),
146 : suCWD.pData,
147 : NULL,
148 : 0,
149 : &process);
150 :
151 : CPPUNIT_ASSERT_EQUAL_MESSAGE
152 : (
153 : "osl_createProcess failed",
154 : osl_Process_E_None, osl_error
155 : );
156 :
157 : TimeValue timeout;
158 : timeout.Seconds = 1;
159 : timeout.Nanosec = 0;
160 :
161 : osl_error = osl_joinProcessWithTimeout(process, &timeout);
162 :
163 : CPPUNIT_ASSERT_EQUAL_MESSAGE
164 : (
165 : "osl_joinProcessWithTimeout returned without timeout failure",
166 : osl_Process_E_TimedOut, osl_error
167 : );
168 :
169 : osl_error = osl_terminateProcess(process);
170 :
171 : CPPUNIT_ASSERT_EQUAL_MESSAGE
172 : (
173 : "osl_terminateProcess failed",
174 : osl_Process_E_None, osl_error
175 : );
176 :
177 : osl_freeProcessHandle(process);
178 : }
179 :
180 : /*-------------------------------------
181 : Start a process and join with this
182 : process specify a timeout so that
183 : osl_joinProcessWithTimeout returns
184 : osl_Process_E_None
185 : -------------------------------------*/
186 :
187 : void osl_joinProcessWithTimeout_without_timeout_failure()
188 : {
189 : oslProcess process;
190 : oslProcessError osl_error = osl_executeProcess(
191 : suExecutableFileURL.pData,
192 : parameters_,
193 : parameters_count_,
194 : osl_Process_NORMAL,
195 : osl_getCurrentSecurity(),
196 : suCWD.pData,
197 : NULL,
198 : 0,
199 : &process);
200 :
201 : CPPUNIT_ASSERT_EQUAL_MESSAGE
202 : (
203 : "osl_createProcess failed",
204 : osl_Process_E_None, osl_error
205 : );
206 :
207 : TimeValue timeout;
208 : timeout.Seconds = 10;
209 : timeout.Nanosec = 0;
210 :
211 : osl_error = osl_joinProcessWithTimeout(process, &timeout);
212 :
213 : CPPUNIT_ASSERT_EQUAL_MESSAGE
214 : (
215 : "osl_joinProcessWithTimeout returned with failure",
216 : osl_Process_E_None, osl_error
217 : );
218 :
219 : osl_freeProcessHandle(process);
220 : }
221 :
222 : /*-------------------------------------
223 : Start a process and join with this
224 : process specify an infinite timeout
225 : -------------------------------------*/
226 :
227 : void osl_joinProcessWithTimeout_infinite()
228 : {
229 : oslProcess process;
230 : oslProcessError osl_error = osl_executeProcess(
231 : suExecutableFileURL.pData,
232 : parameters_,
233 : parameters_count_,
234 : osl_Process_NORMAL,
235 : osl_getCurrentSecurity(),
236 : suCWD.pData,
237 : NULL,
238 : 0,
239 : &process);
240 :
241 : CPPUNIT_ASSERT_EQUAL_MESSAGE
242 : (
243 : "osl_createProcess failed",
244 : osl_Process_E_None, osl_error
245 : );
246 :
247 : osl_error = osl_joinProcessWithTimeout(process, NULL);
248 :
249 : CPPUNIT_ASSERT_EQUAL_MESSAGE
250 : (
251 : "osl_joinProcessWithTimeout returned with failure",
252 : osl_Process_E_None, osl_error
253 : );
254 :
255 : osl_freeProcessHandle(process);
256 : }
257 :
258 : /*-------------------------------------
259 : Start a process and join with this
260 : process using osl_joinProcess
261 : -------------------------------------*/
262 :
263 : void osl_joinProcess()
264 : {
265 : oslProcess process;
266 : oslProcessError osl_error = osl_executeProcess(
267 : suExecutableFileURL.pData,
268 : parameters_,
269 : parameters_count_,
270 : osl_Process_NORMAL,
271 : osl_getCurrentSecurity(),
272 : suCWD.pData,
273 : NULL,
274 : 0,
275 : &process);
276 :
277 : CPPUNIT_ASSERT_EQUAL_MESSAGE
278 : (
279 : "osl_createProcess failed",
280 : osl_Process_E_None, osl_error
281 : );
282 :
283 : osl_error = ::osl_joinProcess(process);
284 :
285 : CPPUNIT_ASSERT_EQUAL_MESSAGE
286 : (
287 : "osl_joinProcess returned with failure",
288 : osl_Process_E_None, osl_error
289 : );
290 :
291 : osl_freeProcessHandle(process);
292 : }
293 :
294 : CPPUNIT_TEST_SUITE(Test_osl_joinProcess);
295 : CPPUNIT_TEST(osl_joinProcessWithTimeout_timeout_failure);
296 : CPPUNIT_TEST(osl_joinProcessWithTimeout_without_timeout_failure);
297 : CPPUNIT_TEST(osl_joinProcessWithTimeout_infinite);
298 : CPPUNIT_TEST(osl_joinProcess);
299 : CPPUNIT_TEST_SUITE_END();
300 : };
301 :
302 : //#########################################################
303 :
304 : typedef std::vector<std::string, rtl::Allocator<std::string> > string_container_t;
305 : typedef string_container_t::const_iterator string_container_const_iter_t;
306 : typedef string_container_t::iterator string_container_iter_t;
307 :
308 : //#########################################################
309 12 : class exclude : public std::unary_function<std::string, bool>
310 : {
311 : public:
312 : //------------------------------------------------
313 2 : exclude(const string_container_t& exclude_list)
314 2 : {
315 2 : string_container_const_iter_t iter = exclude_list.begin();
316 2 : string_container_const_iter_t iter_end = exclude_list.end();
317 8 : for (/**/; iter != iter_end; ++iter)
318 6 : exclude_list_.push_back(env_var_name(*iter));
319 2 : }
320 :
321 : //------------------------------------------------
322 1473 : bool operator() (const std::string& env_var) const
323 : {
324 1473 : return (exclude_list_.end() !=
325 : std::find(
326 : exclude_list_.begin(),
327 : exclude_list_.end(),
328 2946 : env_var_name(env_var)));
329 : }
330 :
331 : private:
332 : //-------------------------------------------------
333 : // extract the name from an environment variable
334 : // that is given in the form "NAME=VALUE"
335 1479 : std::string env_var_name(const std::string& env_var) const
336 : {
337 : std::string::size_type pos_equal_sign =
338 1479 : env_var.find_first_of("=");
339 :
340 1479 : if (std::string::npos != pos_equal_sign)
341 1479 : return std::string(env_var, 0, pos_equal_sign);
342 :
343 0 : return std::string();
344 : }
345 :
346 : private:
347 : string_container_t exclude_list_;
348 : };
349 :
350 : namespace
351 : {
352 20 : class starts_with
353 : : public std::unary_function<const std::string&, bool>
354 : {
355 : private:
356 : const std::string m_rString;
357 : public:
358 4 : starts_with(const char *pString) : m_rString(pString) {}
359 2943 : bool operator()(const std::string &rEntry) const
360 : {
361 2943 : return rEntry.find(m_rString) == 0;
362 : }
363 : };
364 :
365 4 : void tidy_container(string_container_t &env_container)
366 : {
367 : //sort them because there are no guarantees to ordering
368 4 : std::sort(env_container.begin(), env_container.end());
369 : //remove LD_PRELOAD because valgrind injects that into the
370 : //parent process
371 : env_container.erase(std::remove_if(env_container.begin(), env_container.end(),
372 4 : starts_with("LD_PRELOAD=")), env_container.end());
373 4 : }
374 : }
375 :
376 : #ifdef WNT
377 : void read_parent_environment(string_container_t* env_container)
378 : {
379 : LPTSTR env = reinterpret_cast<LPTSTR>(GetEnvironmentStrings());
380 : LPTSTR p = env;
381 :
382 : while (size_t l = _tcslen(p))
383 : {
384 : env_container->push_back(std::string(p));
385 : p += l + 1;
386 : }
387 : FreeEnvironmentStrings(env);
388 : tidy_container(*env_container);
389 : }
390 : #else
391 2 : void read_parent_environment(string_container_t* env_container)
392 : {
393 1472 : for (int i = 0; NULL != environ[i]; i++)
394 1470 : env_container->push_back(std::string(environ[i]));
395 2 : tidy_container(*env_container);
396 2 : }
397 : #endif
398 :
399 : //#########################################################
400 6 : class Test_osl_executeProcess : public CppUnit::TestFixture
401 : {
402 : const OUString env_param_;
403 :
404 : OUString temp_file_url_;
405 : OUString temp_file_path_;
406 : rtl_uString* parameters_[2];
407 : int parameters_count_;
408 : OUString suCWD;
409 : OUString suExecutableFileURL;
410 :
411 : public:
412 :
413 : //------------------------------------------------
414 : // ctor
415 3 : Test_osl_executeProcess() :
416 : env_param_(OUString("-env")),
417 3 : parameters_count_(2)
418 : {
419 3 : parameters_[0] = env_param_.pData;
420 3 : suCWD = getExecutablePath();
421 3 : suExecutableFileURL = suCWD;
422 3 : suExecutableFileURL += rtl::OUString("/");
423 3 : suExecutableFileURL += EXECUTABLE_NAME;
424 3 : }
425 :
426 : //------------------------------------------------
427 3 : virtual void setUp()
428 : {
429 3 : temp_file_path_ = create_temp_file(temp_file_url_);
430 3 : parameters_[1] = temp_file_path_.pData;
431 3 : }
432 :
433 3 : virtual void tearDown()
434 : {
435 3 : osl::File::remove(temp_file_url_);
436 3 : }
437 :
438 : //------------------------------------------------
439 3 : OUString create_temp_file(OUString &temp_file_url)
440 : {
441 3 : FileBase::RC rc = FileBase::createTempFile(0, 0, &temp_file_url);
442 3 : CPPUNIT_ASSERT_EQUAL_MESSAGE("createTempFile failed", FileBase::E_None, rc);
443 :
444 3 : OUString temp_file_path;
445 3 : rc = FileBase::getSystemPathFromFileURL(temp_file_url, temp_file_path);
446 3 : CPPUNIT_ASSERT_EQUAL_MESSAGE("getSystemPathFromFileURL failed", FileBase::E_None, rc);
447 :
448 3 : return temp_file_path;
449 : }
450 :
451 : //------------------------------------------------
452 2 : void read_child_environment(string_container_t* env_container)
453 : {
454 : OString temp_file_name = OUStringToOString(OUString(
455 2 : parameters_[1]), osl_getThreadTextEncoding());
456 2 : std::ifstream file(temp_file_name.getStr());
457 :
458 4 : CPPUNIT_ASSERT_MESSAGE
459 : (
460 : "I/O error, cannot open child environment file",
461 : file.is_open()
462 2 : );
463 :
464 2 : std::string line;
465 2 : line.reserve(1024);
466 1477 : while (std::getline(file, line, '\0'))
467 1473 : env_container->push_back(line);
468 2 : tidy_container(*env_container);
469 2 : }
470 :
471 : //------------------------------------------------
472 : // environment of the child process that was
473 : // started. The child process writes his
474 : // environment into a file
475 1 : bool compare_environments()
476 : {
477 1 : string_container_t parent_env;
478 1 : read_parent_environment(&parent_env);
479 :
480 1 : string_container_t child_env;
481 1 : read_child_environment(&child_env);
482 :
483 1 : return ((parent_env.size() == child_env.size()) &&
484 1 : (std::equal(child_env.begin(), child_env.end(), parent_env.begin())));
485 : }
486 :
487 : //------------------------------------------------
488 : // compare the equal environment parts and the
489 : // different part of the child environment
490 1 : bool compare_merged_environments(const string_container_t& different_env_vars)
491 : {
492 1 : string_container_t parent_env;
493 1 : read_parent_environment(&parent_env);
494 :
495 : #if OSL_DEBUG_LEVEL > 1
496 : for (string_container_t::const_iterator iter = parent_env.begin(), end = parent_env.end(); iter != end; ++iter)
497 : std::cerr << "initially parent env: " << *iter << std::endl;
498 : #endif
499 :
500 : //remove the environment variables that we have changed
501 : //in the child environment from the read parent environment
502 : parent_env.erase(
503 : std::remove_if(parent_env.begin(), parent_env.end(), exclude(different_env_vars)),
504 1 : parent_env.end());
505 :
506 : #if OSL_DEBUG_LEVEL > 1
507 : for (string_container_t::const_iterator iter = parent_env.begin(), end = parent_env.end(); iter != end; ++iter)
508 : std::cerr << "stripped parent env: " << *iter << std::endl;
509 : #endif
510 :
511 : //read the child environment and exclude the variables that
512 : //are different
513 1 : string_container_t child_env;
514 1 : read_child_environment(&child_env);
515 :
516 : #if OSL_DEBUG_LEVEL > 1
517 : for (string_container_t::const_iterator iter = child_env.begin(), end = child_env.end(); iter != end; ++iter)
518 : std::cerr << "initial child env: " << *iter << std::endl;
519 : #endif
520 : //partition the child environment into the variables that
521 : //are different to the parent environment (they come first)
522 : //and the variables that should be equal between parent
523 : //and child environment
524 : string_container_iter_t iter_logical_end =
525 1 : std::stable_partition(child_env.begin(), child_env.end(), exclude(different_env_vars));
526 :
527 1 : string_container_t different_child_env_vars(child_env.begin(), iter_logical_end);
528 1 : child_env.erase(child_env.begin(), iter_logical_end);
529 :
530 : #if OSL_DEBUG_LEVEL > 1
531 : for (string_container_t::const_iterator iter = child_env.begin(), end = child_env.end(); iter != end; ++iter)
532 : std::cerr << "stripped child env: " << *iter << std::endl;
533 : #endif
534 :
535 1 : bool common_env_size_equals = (parent_env.size() == child_env.size());
536 1 : bool common_env_content_equals = std::equal(child_env.begin(), child_env.end(), parent_env.begin());
537 :
538 : #if OSL_DEBUG_LEVEL > 1
539 : for (string_container_t::const_iterator iter = different_env_vars.begin(), end = different_env_vars.end(); iter != end; ++iter)
540 : std::cerr << "different should be: " << *iter << std::endl;
541 : #endif
542 :
543 :
544 : #if OSL_DEBUG_LEVEL > 1
545 : for (string_container_t::const_iterator iter = different_child_env_vars.begin(), end = different_child_env_vars.end(); iter != end; ++iter)
546 : std::cerr << "different are: " << *iter << std::endl;
547 : #endif
548 :
549 1 : bool different_env_size_equals = (different_child_env_vars.size() == different_env_vars.size());
550 : bool different_env_content_equals =
551 1 : std::equal(different_env_vars.begin(), different_env_vars.end(), different_child_env_vars.begin());
552 :
553 : return (common_env_size_equals && common_env_content_equals &&
554 1 : different_env_size_equals && different_env_content_equals);
555 : }
556 :
557 : //------------------------------------------------
558 : // test that parent and child process have the
559 : // same environment when osl_executeProcess will
560 : // be called with out setting new environment
561 : // variables
562 1 : void osl_execProc_parent_equals_child_environment()
563 : {
564 : oslProcess process;
565 : oslProcessError osl_error = osl_executeProcess(
566 : suExecutableFileURL.pData,
567 : parameters_,
568 : parameters_count_,
569 : osl_Process_NORMAL,
570 : NULL,
571 : suCWD.pData,
572 : NULL,
573 : 0,
574 1 : &process);
575 :
576 2 : CPPUNIT_ASSERT_EQUAL_MESSAGE
577 : (
578 : "osl_createProcess failed",
579 : osl_Process_E_None, osl_error
580 1 : );
581 :
582 1 : osl_error = ::osl_joinProcess(process);
583 :
584 2 : CPPUNIT_ASSERT_EQUAL_MESSAGE
585 : (
586 : "osl_joinProcess returned with failure",
587 : osl_Process_E_None, osl_error
588 1 : );
589 :
590 1 : osl_freeProcessHandle(process);
591 :
592 2 : CPPUNIT_ASSERT_MESSAGE
593 : (
594 : "Parent and child environment not equal",
595 : compare_environments()
596 1 : );
597 1 : }
598 :
599 : //------------------------------------------------
600 : #define ENV1 "PAT=a:\\"
601 : #define ENV2 "PATHb=b:\\"
602 : #define ENV3 "Patha=c:\\"
603 : #define ENV4 "Patha=d:\\"
604 :
605 1 : void osl_execProc_merged_child_environment()
606 : {
607 : rtl_uString* child_env[4];
608 1 : OUString env1(ENV1);
609 1 : OUString env2(ENV2);
610 1 : OUString env3(ENV3);
611 1 : OUString env4(ENV4);
612 :
613 1 : child_env[0] = env1.pData;
614 1 : child_env[1] = env2.pData;
615 1 : child_env[2] = env3.pData;
616 1 : child_env[3] = env4.pData;
617 :
618 : oslProcess process;
619 : oslProcessError osl_error = osl_executeProcess(
620 : suExecutableFileURL.pData,
621 : parameters_,
622 : parameters_count_,
623 : osl_Process_NORMAL,
624 : NULL,
625 : suCWD.pData,
626 : child_env,
627 : SAL_N_ELEMENTS(child_env),
628 1 : &process);
629 :
630 2 : CPPUNIT_ASSERT_EQUAL_MESSAGE
631 : (
632 : "osl_createProcess failed",
633 : osl_Process_E_None, osl_error
634 1 : );
635 :
636 1 : osl_error = ::osl_joinProcess(process);
637 :
638 2 : CPPUNIT_ASSERT_EQUAL_MESSAGE
639 : (
640 : "osl_joinProcess returned with failure",
641 : osl_Process_E_None, osl_error
642 1 : );
643 :
644 1 : osl_freeProcessHandle(process);
645 :
646 1 : string_container_t different_child_env_vars;
647 1 : different_child_env_vars.push_back(ENV1);
648 1 : different_child_env_vars.push_back(ENV2);
649 1 : different_child_env_vars.push_back(ENV4);
650 :
651 2 : CPPUNIT_ASSERT_MESSAGE
652 : (
653 : "osl_execProc_merged_child_environment",
654 : compare_merged_environments(different_child_env_vars)
655 2 : );
656 1 : }
657 :
658 1 : void osl_execProc_test_batch()
659 : {
660 : oslProcess process;
661 : #if defined(WNT)
662 : rtl::OUString suBatch = suCWD + rtl::OUString("/") + rtl::OUString("batch.bat");
663 : #else
664 1 : rtl::OUString suBatch = suCWD + rtl::OUString("/") + rtl::OUString("batch.sh");
665 : #endif
666 : oslProcessError osl_error = osl_executeProcess(
667 : suBatch.pData,
668 : NULL,
669 : 0,
670 : osl_Process_NORMAL,
671 : NULL,
672 : suCWD.pData,
673 : NULL,
674 : 0,
675 1 : &process);
676 :
677 2 : CPPUNIT_ASSERT_EQUAL_MESSAGE
678 : (
679 : "osl_createProcess failed",
680 : osl_Process_E_None, osl_error
681 1 : );
682 :
683 1 : osl_error = ::osl_joinProcess(process);
684 :
685 2 : CPPUNIT_ASSERT_EQUAL_MESSAGE
686 : (
687 : "osl_joinProcess returned with failure",
688 : osl_Process_E_None, osl_error
689 1 : );
690 :
691 1 : osl_freeProcessHandle(process);
692 1 : }
693 :
694 : void osl_execProc_exe_name_in_argument_list()
695 : {
696 : rtl_uString* params[3];
697 :
698 : params[0] = suExecutableFileURL.pData;
699 : params[1] = env_param_.pData;
700 : params[2] = temp_file_path_.pData;
701 : oslProcess process;
702 : oslProcessError osl_error = osl_executeProcess(
703 : NULL,
704 : params,
705 : 3,
706 : osl_Process_NORMAL,
707 : NULL,
708 : suCWD.pData,
709 : NULL,
710 : 0,
711 : &process);
712 :
713 : CPPUNIT_ASSERT_EQUAL_MESSAGE
714 : (
715 : "osl_createProcess failed",
716 : osl_Process_E_None, osl_error
717 : );
718 :
719 : osl_error = ::osl_joinProcess(process);
720 :
721 : CPPUNIT_ASSERT_EQUAL_MESSAGE
722 : (
723 : "osl_joinProcess returned with failure",
724 : osl_Process_E_None, osl_error
725 : );
726 :
727 : osl_freeProcessHandle(process);
728 : }
729 :
730 2 : CPPUNIT_TEST_SUITE(Test_osl_executeProcess);
731 : //TODO: Repair these under windows.
732 : #ifndef WNT
733 1 : CPPUNIT_TEST(osl_execProc_parent_equals_child_environment);
734 1 : CPPUNIT_TEST(osl_execProc_merged_child_environment);
735 : #endif
736 1 : CPPUNIT_TEST(osl_execProc_test_batch);
737 : ///TODO: Repair test (or tested function ;-) - test fails.
738 : // CPPUNIT_TEST(osl_execProc_exe_name_in_argument_list);
739 2 : CPPUNIT_TEST_SUITE_END();
740 : };
741 :
742 : //#####################################
743 : // register test suites
744 : //CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test_osl_joinProcess, "Test_osl_joinProcess");
745 1 : CPPUNIT_TEST_SUITE_REGISTRATION(Test_osl_executeProcess);
746 :
747 4 : CPPUNIT_PLUGIN_IMPLEMENT();
748 :
749 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|