[VM/Runtime] - Do not try to resolve exec path for default namespace

TEST=new test added
Bug:54516
Change-Id: I67b1fe7ee07db342d328e5272ddca5411fd5df28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345320
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
This commit is contained in:
asiva 2024-01-11 19:12:52 +00:00 committed by Commit Queue
parent 9c7d3e4152
commit e518b8c3be
5 changed files with 31 additions and 2 deletions

View file

@ -451,7 +451,7 @@ class ProcessStarter {
// be reported to the parent.
bool FindPathInNamespace(char* realpath, intptr_t realpath_size) {
// Perform a PATH search if there's no slash in the path.
if (strchr(path_, '/') == nullptr) {
if (Namespace::IsDefault(namespc_) || strchr(path_, '/') == nullptr) {
// TODO(zra): If there is a non-default namespace, the entries in PATH
// should be treated as relative to the namespace.
strncpy(realpath, path_, realpath_size);

View file

@ -452,7 +452,7 @@ class ProcessStarter {
// be reported to the parent.
bool FindPathInNamespace(char* realpath, intptr_t realpath_size) {
// Perform a PATH search if there's no slash in the path.
if (strchr(path_, '/') == nullptr) {
if (Namespace::IsDefault(namespc_) || strchr(path_, '/') == nullptr) {
// TODO(zra): If there is a non-default namespace, the entries in PATH
// should be treated as relative to the namespace.
strncpy(realpath, path_, realpath_size);

View file

@ -0,0 +1,24 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:io';
import 'package:expect/expect.dart';
Future<void> main() async {
// Create a shell script that prints the output.
final origDir = Directory.current;
final fileName = "tests/standalone/io/regress_54516_test.sh";
var script = new File("tests/standalone/io/regress_54516_test.sh");
if (!script.existsSync()) {
script = new File("../tests/standalone/io/regress_54516_test.sh");
}
var expectedResult = fileName + Platform.lineTerminator;
Expect.isTrue(script.existsSync());
List<String> args = [];
var result = Process.runSync(script.path, args, runInShell: false);
Expect.stringEquals(result.stdout, expectedResult);
result = Process.runSync(script.path, args, runInShell: true);
Expect.stringEquals(result.stdout, expectedResult);
}

View file

@ -0,0 +1,4 @@
#!/bin/bash
#
echo $0

View file

@ -41,6 +41,7 @@ io/socket_upgrade_to_secure_test: Skip # Issue 27638
[ $system == windows ]
io/process_sync_test: Pass, Timeout # Issue 24596
io/regress_54516_test: SkipByDesign # Test uses a shell script which won't run on windows
io/sleep_test: Pass, Fail # Issue 25757
verbose_gc_to_bmu_test: Skip