[lldb] Rewrite TestAutoInstallMainExecutable logic

The test uses debug info from one binary to debug a different one. This
does not work on macos, and its pure luck that it works elsewhere (the
variable that it inspects happens to have the same address in both).

The purpose of this test is to verify that lldb has not overwritten the
target executable. That can be more easily achieved by checking the exit
code of the binary, so change the test to do that.

Also remove the llgs_test decorator, as it's preventing the test from
running on macos. All the test needs is the platform functionality of
lldb-server, which is available everywhere.

GitOrigin-RevId: 48e3da13519dea3bd91ab7de656c7d46105c2c01
diff --git a/test/API/commands/target/auto-install-main-executable/Makefile b/test/API/commands/target/auto-install-main-executable/Makefile
index 1354ec4..07e6c9a 100644
--- a/test/API/commands/target/auto-install-main-executable/Makefile
+++ b/test/API/commands/target/auto-install-main-executable/Makefile
@@ -1,9 +1,9 @@
 CXX_SOURCES := main.cpp
-CXXFLAGS := -DBUILD=\"stock\"
+CXXFLAGS := -DBUILD=47
 
 a.out: a.device.out
 
 include Makefile.rules
 
 a.device.out:
-	$(CXX) $(CXXFLAGS) -DBUILD=\"device\" -o $@ $(SRCDIR)/main.cpp
+	$(CXX) $(CXXFLAGS) -DBUILD=74 -o $@ $(SRCDIR)/main.cpp
diff --git a/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py b/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
index 862943c..410e1f1 100644
--- a/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
+++ b/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
@@ -15,10 +15,11 @@
     mydir = TestBase.compute_mydir(__file__)
     NO_DEBUG_INFO_TESTCASE = True
 
-    @llgs_test
     @skipIfRemote
     @expectedFailureAll(oslist=["windows"]) # process modules not loaded
     def test_target_auto_install_main_executable(self):
+        if lldbgdbserverutils.get_lldb_server_exe() is None:
+          self.skipTest("lldb-server not found")
         self.build()
 
         hostname = socket.getaddrinfo("localhost", 0, proto=socket.IPPROTO_TCP)[0][4][0]
@@ -69,23 +70,4 @@
                                         (dest.fullpath,
                                             self.getBuildArtifact("a.out")))
 
-        target = self.dbg.GetSelectedTarget()
-        breakpoint = target.BreakpointCreateByName("main")
-
-        launch_info = target.GetLaunchInfo()
-        error = lldb.SBError()
-        process = target.Launch(launch_info, error)
-        self.assertTrue(process, PROCESS_IS_VALID)
-
-        thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
-        self.assertTrue(
-            thread.IsValid(),
-            "There should be a thread stopped due to breakpoint")
-
-        frame = thread.GetFrameAtIndex(0)
-        self.assertEqual(frame.GetFunction().GetName(), "main")
-
-        self.expect("target variable build", substrs=['"device"'],
-                msg="Magic in the binary is wrong")
-
-        process.Continue()
+        self.expect("process launch", substrs=["exited with status = 74"])
diff --git a/test/API/commands/target/auto-install-main-executable/main.cpp b/test/API/commands/target/auto-install-main-executable/main.cpp
index 373f1a7..f9fb997 100644
--- a/test/API/commands/target/auto-install-main-executable/main.cpp
+++ b/test/API/commands/target/auto-install-main-executable/main.cpp
@@ -1,8 +1,5 @@
-#include <cstdio>
+int build = BUILD;
 
-const char* build = BUILD;
-
-int main(int argc, char **argv) {
-  printf("argc: %d\n", argc);
-  return argv[0][0];
+int main() {
+  return BUILD;
 }