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