Edit

kc3-lang/angle/src/common/system_utils.h

Branch :

  • Show log

    Commit

  • Author : Shahbaz Youssefi
    Date : 2019-02-25 16:31:57
    Hash : a9f89313
    Message : Reland "Add system util to execute app and retrieve its output" This reverts commit fe14b2e503a5991aeb033836bb4d525508475b52. Reason for revert: failing test is reworked not to run angle_unittests itself, but another binary. Previously, this test was calling angle_unittests itself, but with a different target. On the bots, that was in turn calling angle_unittests with even more arguments, including the addition of a log file location. Under some configurations, this separate process was thus trying to access files that were already opened by the parent process, leading to a test failure. In this CL, a new helper executable is created for the sake of this unittest. > Revert "Add system util to execute app and retrieve its output" > > This reverts commit c63d95525cde8d28963148bb5894456c1d39018d. > > Reason for revert: Test fails on Win7 > > Original change's description: > > Add system util to execute app and retrieve its output > > > > This will be useful to run external applications, such as benchmarks, > > and process their output. > > > > Bug: angleproject:3125 > > Change-Id: Ic13c69f2e034f4b47498fb2f299c62423c355c4a > > Reviewed-on: https://chromium-review.googlesource.com/c/1452534 > > Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> > > Reviewed-by: Jamie Madill <jmadill@google.com> Bug: angleproject:3125, angleproject:3168 Change-Id: I74815750484a79f33c36e0b4f941d4dd98f99aa5 Reviewed-on: https://chromium-review.googlesource.com/c/1487631 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@google.com> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>

  • src/common/system_utils.h
  • //
    // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    
    // system_utils.h: declaration of OS-specific utility functions
    
    #ifndef COMMON_SYSTEM_UTILS_H_
    #define COMMON_SYSTEM_UTILS_H_
    
    #include "common/Optional.h"
    #include "common/angleutils.h"
    
    namespace angle
    {
    std::string GetExecutablePath();
    std::string GetExecutableDirectory();
    const char *GetSharedLibraryExtension();
    Optional<std::string> GetCWD();
    bool SetCWD(const char *dirName);
    bool SetEnvironmentVar(const char *variableName, const char *value);
    bool UnsetEnvironmentVar(const char *variableName);
    std::string GetEnvironmentVar(const char *variableName);
    const char *GetPathSeparator();
    bool PrependPathToEnvironmentVar(const char *variableName, const char *path);
    
    // Run an application and get the output.  Gets a nullptr-terminated set of args to execute the
    // application with, and returns the stdout and stderr outputs as well as the exit code.
    //
    // Returns false if it fails to actually execute the application.
    bool RunApp(const std::vector<const char *> &args,
                std::string *stdoutOut,
                std::string *stderrOut,
                int *exitCodeOut);
    
    class Library : angle::NonCopyable
    {
      public:
        virtual ~Library() {}
        virtual void *getSymbol(const char *symbolName) = 0;
        virtual void *getNative() const                 = 0;
    
        template <typename FuncT>
        void getAs(const char *symbolName, FuncT *funcOut)
        {
            *funcOut = reinterpret_cast<FuncT>(getSymbol(symbolName));
        }
    };
    
    Library *OpenSharedLibrary(const char *libraryName);
    }  // namespace angle
    
    #endif  // COMMON_SYSTEM_UTILS_H_