adb: win32: make adb_getenv() case-insensitive
adb_getenv() should be case-insensitive just like the real getenv() on
Windows.
Added a unittest for adb_getenv(). In the process, made adb_test link
with -municode so that the environment block is Unicode.
Move wmain() from main.cpp to sysdeps_win32.cpp so that adb_test could
also use it.
Because wmain() moved, it wasn't as easy to do the runtime check to
verify that -municode was used, so do that check in _ensure_env_setup()
since adb_getenv() is called early in adb anyway.
Added a utility ToLower() which is good enough for env vars whose keys
are probably always ASCII to begin with.
Change-Id: I082f7fdee9dfe2c7f76b878528d2f7863df6d8d1
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
diff --git a/adb/Android.mk b/adb/Android.mk
index 543f1eb..a64f48c 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -78,6 +78,9 @@
LIBADB_TEST_darwin_SRCS := \
fdevent_test.cpp \
+LIBADB_TEST_windows_SRCS := \
+ sysdeps_win32_test.cpp \
+
include $(CLEAR_VARS)
LOCAL_CLANG := true
LOCAL_MODULE := libadbd
@@ -153,6 +156,7 @@
LOCAL_SRC_FILES_linux := $(LIBADB_TEST_linux_SRCS)
LOCAL_SRC_FILES_darwin := $(LIBADB_TEST_darwin_SRCS)
+LOCAL_SRC_FILES_windows := $(LIBADB_TEST_windows_SRCS)
LOCAL_SANITIZE := $(adb_host_sanitize)
LOCAL_SHARED_LIBRARIES := libbase
LOCAL_STATIC_LIBRARIES := \
@@ -160,6 +164,8 @@
libcrypto_static \
libcutils \
+# Set entrypoint to wmain from sysdeps_win32.cpp instead of main
+LOCAL_LDFLAGS_windows := -municode
LOCAL_LDLIBS_linux := -lrt -ldl -lpthread
LOCAL_LDLIBS_darwin := -framework CoreFoundation -framework IOKit
LOCAL_LDLIBS_windows := -lws2_32 -luserenv