summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--atrace/Android.mk17
-rw-r--r--atrace/MODULE_LICENSE_APACHE20
-rw-r--r--atrace/NOTICE190
-rw-r--r--atrace/atrace.c607
-rw-r--r--bugmailer/Android.mk12
-rwxr-xr-xbugmailer/bugmailer.sh50
-rwxr-xr-xbugmailer/send_bug5
-rw-r--r--bugmailer/src/com/android/commands/sendbug/SendBug.java180
-rw-r--r--micro_bench/Android.mk12
-rw-r--r--su/su.c87
-rw-r--r--tests/binder/benchmarks/Android.mk1
-rw-r--r--tests/crypto/Android.mk12
-rw-r--r--tests/crypto/get_dm_versions.c57
-rw-r--r--tests/ext4/Android.mk3
-rw-r--r--tests/framebuffer/Android.mk8
-rw-r--r--tests/framebuffer/mdp_test.c324
-rw-r--r--tests/iptables/qtaguid/Android.mk2
-rw-r--r--tests/storage/Android.mk17
-rw-r--r--tests/storage/opentest.c95
-rw-r--r--tests/storage/wipe_blkdev.c131
-rw-r--r--tests/wifi/stress/Android.mk2
21 files changed, 402 insertions, 1410 deletions
diff --git a/atrace/Android.mk b/atrace/Android.mk
deleted file mode 100644
index 12526d02..00000000
--- a/atrace/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2012 The Android Open Source Project
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= atrace.c
-
-LOCAL_C_INCLUDES += external/zlib
-LOCAL_CFLAGS += -std=c99
-
-LOCAL_MODULE:= atrace
-
-LOCAL_MODULE_TAGS:= optional
-
-LOCAL_SHARED_LIBRARIES := libz
-
-include $(BUILD_EXECUTABLE)
diff --git a/atrace/MODULE_LICENSE_APACHE2 b/atrace/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29b..00000000
--- a/atrace/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/atrace/NOTICE b/atrace/NOTICE
deleted file mode 100644
index c77f135e..00000000
--- a/atrace/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2012, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/atrace/atrace.c b/atrace/atrace.c
deleted file mode 100644
index 2d9b4f84..00000000
--- a/atrace/atrace.c
+++ /dev/null
@@ -1,607 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/sendfile.h>
-#include <time.h>
-#include <zlib.h>
-
-#define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0])))
-
-/* Command line options */
-static int g_traceDurationSeconds = 5;
-static bool g_traceSchedSwitch = false;
-static bool g_traceFrequency = false;
-static bool g_traceBusUtilization = false;
-static bool g_traceCpuIdle = false;
-static bool g_traceDisk = false;
-static bool g_traceGovernorLoad = false;
-static bool g_traceSync = false;
-static bool g_traceWorkqueue = false;
-static bool g_traceOverwrite = false;
-static int g_traceBufferSizeKB = 2048;
-static bool g_compress = false;
-static bool g_nohup = false;
-static int g_initialSleepSecs = 0;
-
-/* Global state */
-static bool g_traceAborted = false;
-
-/* Sys file paths */
-static const char* k_traceClockPath =
- "/sys/kernel/debug/tracing/trace_clock";
-
-static const char* k_traceBufferSizePath =
- "/sys/kernel/debug/tracing/buffer_size_kb";
-
-static const char* k_tracingOverwriteEnablePath =
- "/sys/kernel/debug/tracing/options/overwrite";
-
-static const char* k_schedSwitchEnablePath =
- "/sys/kernel/debug/tracing/events/sched/sched_switch/enable";
-
-static const char* k_schedWakeupEnablePath =
- "/sys/kernel/debug/tracing/events/sched/sched_wakeup/enable";
-
-static const char* k_memoryBusEnablePath =
- "/sys/kernel/debug/tracing/events/memory_bus/enable";
-
-static const char* k_cpuFreqEnablePath =
- "/sys/kernel/debug/tracing/events/power/cpu_frequency/enable";
-
-static const char *k_clockSetRateEnablePath =
- "/sys/kernel/debug/tracing/events/power/clock_set_rate/enable";
-
-static const char* k_cpuIdleEnablePath =
- "/sys/kernel/debug/tracing/events/power/cpu_idle/enable";
-
-static const char* k_governorLoadEnablePath =
- "/sys/kernel/debug/tracing/events/cpufreq_interactive/enable";
-
-static const char* k_syncEnablePath =
- "/sys/kernel/debug/tracing/events/sync/enable";
-
-static const char* k_workqueueEnablePath =
- "/sys/kernel/debug/tracing/events/workqueue/enable";
-
-static const char* k_diskEnablePaths[] = {
- "/sys/kernel/debug/tracing/events/ext4/ext4_sync_file_enter/enable",
- "/sys/kernel/debug/tracing/events/ext4/ext4_sync_file_exit/enable",
- "/sys/kernel/debug/tracing/events/block/block_rq_issue/enable",
- "/sys/kernel/debug/tracing/events/block/block_rq_complete/enable",
-};
-
-static const char* k_tracingOnPath =
- "/sys/kernel/debug/tracing/tracing_on";
-
-static const char* k_tracePath =
- "/sys/kernel/debug/tracing/trace";
-
-static const char* k_traceMarkerPath =
- "/sys/kernel/debug/tracing/trace_marker";
-
-// Check whether a file exists.
-static bool fileExists(const char* filename) {
- return access(filename, F_OK) != -1;
-}
-
-// Write a string to a file, returning true if the write was successful.
-bool writeStr(const char* filename, const char* str)
-{
- int fd = open(filename, O_WRONLY);
- if (fd == -1) {
- fprintf(stderr, "error opening %s: %s (%d)\n", filename,
- strerror(errno), errno);
- return false;
- }
-
- bool ok = true;
- ssize_t len = strlen(str);
- if (write(fd, str, len) != len) {
- fprintf(stderr, "error writing to %s: %s (%d)\n", filename,
- strerror(errno), errno);
- ok = false;
- }
-
- close(fd);
-
- return ok;
-}
-
-// Enable or disable a kernel option by writing a "1" or a "0" into a /sys file.
-static bool setKernelOptionEnable(const char* filename, bool enable)
-{
- return writeStr(filename, enable ? "1" : "0");
-}
-
-// Enable or disable a collection of kernel options by writing a "1" or a "0" into each /sys file.
-static bool setMultipleKernelOptionsEnable(const char** filenames, size_t count, bool enable)
-{
- bool result = true;
- for (size_t i = 0; i < count; i++) {
- result &= setKernelOptionEnable(filenames[i], enable);
- }
- return result;
-}
-
-// Enable or disable overwriting of the kernel trace buffers. Disabling this
-// will cause tracing to stop once the trace buffers have filled up.
-static bool setTraceOverwriteEnable(bool enable)
-{
- return setKernelOptionEnable(k_tracingOverwriteEnablePath, enable);
-}
-
-// Enable or disable tracing of the kernel scheduler switching.
-static bool setSchedSwitchTracingEnable(bool enable)
-{
- bool ok = true;
- ok &= setKernelOptionEnable(k_schedSwitchEnablePath, enable);
- ok &= setKernelOptionEnable(k_schedWakeupEnablePath, enable);
- return ok;
-}
-
-// Enable or disable tracing of the Bus utilization.
-static bool setBusUtilizationTracingEnable(bool enable)
-{
- bool ok = true, oneSet = false;
- // these can be platform specific so make sure that at least
- // one succeeds.
- if (fileExists(k_memoryBusEnablePath)) {
- ok &= setKernelOptionEnable(k_memoryBusEnablePath, enable);
- oneSet |= ok;
- }
- return ok && (oneSet || !enable);
-}
-
-// Enable or disable tracing of the CPU clock frequency.
-static bool setFrequencyTracingEnable(bool enable)
-{
- bool ok = true;
- ok &= setKernelOptionEnable(k_cpuFreqEnablePath, enable);
- if (fileExists(k_clockSetRateEnablePath)) {
- ok &= setKernelOptionEnable(k_clockSetRateEnablePath, enable);
- }
- return ok;
-}
-
-// Enable or disable tracing of CPU idle events.
-static bool setCpuIdleTracingEnable(bool enable)
-{
- return setKernelOptionEnable(k_cpuIdleEnablePath, enable);
-}
-
-// Enable or disable tracing of the interactive CPU frequency governor's idea of
-// the CPU load.
-static bool setGovernorLoadTracingEnable(bool enable)
-{
- bool ok = true;
- if (fileExists(k_governorLoadEnablePath) || enable) {
- ok &= setKernelOptionEnable(k_governorLoadEnablePath, enable);
- }
- return ok;
-}
-
-// Enable or disable tracing of sync timelines and waits.
-static bool setSyncTracingEnabled(bool enable)
-{
- bool ok = true;
- if (fileExists(k_syncEnablePath) || enable) {
- ok &= setKernelOptionEnable(k_syncEnablePath, enable);
- }
- return ok;
-}
-
-// Enable or disable tracing of the kernel workqueues.
-static bool setWorkqueueTracingEnabled(bool enable)
-{
- return setKernelOptionEnable(k_workqueueEnablePath, enable);
-}
-
-// Enable or disable tracing of disk I/O.
-static bool setDiskTracingEnabled(bool enable)
-{
- return setMultipleKernelOptionsEnable(k_diskEnablePaths, NELEM(k_diskEnablePaths), enable);
-}
-
-// Enable or disable kernel tracing.
-static bool setTracingEnabled(bool enable)
-{
- return setKernelOptionEnable(k_tracingOnPath, enable);
-}
-
-// Clear the contents of the kernel trace.
-static bool clearTrace()
-{
- int traceFD = creat(k_tracePath, 0);
- if (traceFD == -1) {
- fprintf(stderr, "error truncating %s: %s (%d)\n", k_tracePath,
- strerror(errno), errno);
- return false;
- }
-
- close(traceFD);
-
- return true;
-}
-
-// Set the size of the kernel's trace buffer in kilobytes.
-static bool setTraceBufferSizeKB(int size)
-{
- char str[32] = "1";
- int len;
- if (size < 1) {
- size = 1;
- }
- snprintf(str, 32, "%d", size);
- return writeStr(k_traceBufferSizePath, str);
-}
-
-// Enable or disable the kernel's use of the global clock. Disabling the global
-// clock will result in the kernel using a per-CPU local clock.
-static bool setGlobalClockEnable(bool enable)
-{
- return writeStr(k_traceClockPath, enable ? "global" : "local");
-}
-
-// Enable tracing in the kernel.
-static bool startTrace(bool isRoot)
-{
- bool ok = true;
-
- // Set up the tracing options that don't require root.
- ok &= setTraceOverwriteEnable(g_traceOverwrite);
- ok &= setSchedSwitchTracingEnable(g_traceSchedSwitch);
- ok &= setFrequencyTracingEnable(g_traceFrequency);
- ok &= setCpuIdleTracingEnable(g_traceCpuIdle);
- ok &= setGovernorLoadTracingEnable(g_traceGovernorLoad);
- ok &= setTraceBufferSizeKB(g_traceBufferSizeKB);
- ok &= setGlobalClockEnable(true);
-
- // Set up the tracing options that do require root. The options that
- // require root should have errored out earlier if we're not running as
- // root.
- if (isRoot) {
- ok &= setBusUtilizationTracingEnable(g_traceBusUtilization);
- ok &= setSyncTracingEnabled(g_traceSync);
- ok &= setWorkqueueTracingEnabled(g_traceWorkqueue);
- ok &= setDiskTracingEnabled(g_traceDisk);
- }
-
- // Enable tracing.
- ok &= setTracingEnabled(true);
-
- if (!ok) {
- fprintf(stderr, "error: unable to start trace\n");
- }
-
- return ok;
-}
-
-// Disable tracing in the kernel.
-static void stopTrace(bool isRoot)
-{
- // Disable tracing.
- setTracingEnabled(false);
-
- // Set the options back to their defaults.
- setTraceOverwriteEnable(true);
- setSchedSwitchTracingEnable(false);
- setFrequencyTracingEnable(false);
- setGovernorLoadTracingEnable(false);
- setGlobalClockEnable(false);
-
- if (isRoot) {
- setBusUtilizationTracingEnable(false);
- setSyncTracingEnabled(false);
- setWorkqueueTracingEnabled(false);
- setDiskTracingEnabled(false);
- }
-
- // Note that we can't reset the trace buffer size here because that would
- // clear the trace before we've read it.
-}
-
-// Read the current kernel trace and write it to stdout.
-static void dumpTrace()
-{
- int traceFD = open(k_tracePath, O_RDWR);
- if (traceFD == -1) {
- fprintf(stderr, "error opening %s: %s (%d)\n", k_tracePath,
- strerror(errno), errno);
- return;
- }
-
- if (g_compress) {
- z_stream zs;
- uint8_t *in, *out;
- int result, flush;
-
- bzero(&zs, sizeof(zs));
- result = deflateInit(&zs, Z_DEFAULT_COMPRESSION);
- if (result != Z_OK) {
- fprintf(stderr, "error initializing zlib: %d\n", result);
- close(traceFD);
- return;
- }
-
- const size_t bufSize = 64*1024;
- in = (uint8_t*)malloc(bufSize);
- out = (uint8_t*)malloc(bufSize);
- flush = Z_NO_FLUSH;
-
- zs.next_out = out;
- zs.avail_out = bufSize;
-
- do {
-
- if (zs.avail_in == 0) {
- // More input is needed.
- result = read(traceFD, in, bufSize);
- if (result < 0) {
- fprintf(stderr, "error reading trace: %s (%d)\n",
- strerror(errno), errno);
- result = Z_STREAM_END;
- break;
- } else if (result == 0) {
- flush = Z_FINISH;
- } else {
- zs.next_in = in;
- zs.avail_in = result;
- }
- }
-
- if (zs.avail_out == 0) {
- // Need to write the output.
- result = write(STDOUT_FILENO, out, bufSize);
- if ((size_t)result < bufSize) {
- fprintf(stderr, "error writing deflated trace: %s (%d)\n",
- strerror(errno), errno);
- result = Z_STREAM_END; // skip deflate error message
- zs.avail_out = bufSize; // skip the final write
- break;
- }
- zs.next_out = out;
- zs.avail_out = bufSize;
- }
-
- } while ((result = deflate(&zs, flush)) == Z_OK);
-
- if (result != Z_STREAM_END) {
- fprintf(stderr, "error deflating trace: %s\n", zs.msg);
- }
-
- if (zs.avail_out < bufSize) {
- size_t bytes = bufSize - zs.avail_out;
- result = write(STDOUT_FILENO, out, bytes);
- if ((size_t)result < bytes) {
- fprintf(stderr, "error writing deflated trace: %s (%d)\n",
- strerror(errno), errno);
- }
- }
-
- result = deflateEnd(&zs);
- if (result != Z_OK) {
- fprintf(stderr, "error cleaning up zlib: %d\n", result);
- }
-
- free(in);
- free(out);
- } else {
- ssize_t sent = 0;
- while ((sent = sendfile(STDOUT_FILENO, traceFD, NULL, 64*1024*1024)) > 0);
- if (sent == -1) {
- fprintf(stderr, "error dumping trace: %s (%d)\n", strerror(errno),
- errno);
- }
- }
-
- close(traceFD);
-}
-
-// Print the command usage help to stderr.
-static void showHelp(const char *cmd)
-{
- fprintf(stderr, "usage: %s [options]\n", cmd);
- fprintf(stderr, "options include:\n"
- " -b N use a trace buffer size of N KB\n"
- " -c trace into a circular buffer\n"
- " -d trace disk I/O\n"
- " -f trace clock frequency changes\n"
- " -l trace CPU frequency governor load\n"
- " -s trace the kernel scheduler switches\n"
- " -t N trace for N seconds [defualt 5]\n"
- " -u trace bus utilization\n"
- " -w trace the kernel workqueue\n"
- " -y trace sync timelines and waits\n"
- " -z compress the trace dump\n");
-}
-
-static void handleSignal(int signo) {
- if (!g_nohup) {
- g_traceAborted = true;
- }
-}
-
-static void registerSigHandler() {
- struct sigaction sa;
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- sa.sa_handler = handleSignal;
- sigaction(SIGHUP, &sa, NULL);
- sigaction(SIGINT, &sa, NULL);
- sigaction(SIGQUIT, &sa, NULL);
- sigaction(SIGTERM, &sa, NULL);
-}
-
-int main(int argc, char **argv)
-{
- bool isRoot = (getuid() == 0);
-
- if (argc == 2 && 0 == strcmp(argv[1], "--help")) {
- showHelp(argv[0]);
- exit(0);
- }
-
- for (;;) {
- int ret;
-
- ret = getopt(argc, argv, "b:cidflst:uwyznS:");
-
- if (ret < 0) {
- break;
- }
-
- switch(ret) {
- case 'b':
- g_traceBufferSizeKB = atoi(optarg);
- break;
-
- case 'c':
- g_traceOverwrite = true;
- break;
-
- case 'i':
- g_traceCpuIdle = true;
- break;
-
- case 'l':
- g_traceGovernorLoad = true;
- break;
-
- case 'd':
- if (!isRoot) {
- fprintf(stderr, "error: tracing disk activity requires root privileges\n");
- exit(1);
- }
- g_traceDisk = true;
- break;
-
- case 'f':
- g_traceFrequency = true;
- break;
-
- case 'n':
- g_nohup = true;
- break;
-
- case 's':
- g_traceSchedSwitch = true;
- break;
-
- case 'S':
- g_initialSleepSecs = atoi(optarg);
- break;
-
- case 't':
- g_traceDurationSeconds = atoi(optarg);
- break;
-
- case 'u':
- if (!isRoot) {
- fprintf(stderr, "error: tracing bus utilization requires root privileges\n");
- exit(1);
- }
- g_traceBusUtilization = true;
- break;
-
- case 'w':
- if (!isRoot) {
- fprintf(stderr, "error: tracing kernel work queues requires root privileges\n");
- exit(1);
- }
- g_traceWorkqueue = true;
- break;
-
- case 'y':
- if (!isRoot) {
- fprintf(stderr, "error: tracing sync requires root privileges\n");
- exit(1);
- }
- g_traceSync = true;
- break;
-
- case 'z':
- g_compress = true;
- break;
-
- default:
- fprintf(stderr, "\n");
- showHelp(argv[0]);
- exit(-1);
- break;
- }
- }
-
- registerSigHandler();
-
- if (g_initialSleepSecs > 0) {
- sleep(g_initialSleepSecs);
- }
-
- bool ok = startTrace(isRoot);
-
- if (ok) {
- printf("capturing trace...");
- fflush(stdout);
-
- // We clear the trace after starting it because tracing gets enabled for
- // each CPU individually in the kernel. Having the beginning of the trace
- // contain entries from only one CPU can cause "begin" entries without a
- // matching "end" entry to show up if a task gets migrated from one CPU to
- // another.
- ok = clearTrace();
-
- if (ok) {
- // Sleep to allow the trace to be captured.
- struct timespec timeLeft;
- timeLeft.tv_sec = g_traceDurationSeconds;
- timeLeft.tv_nsec = 0;
- do {
- if (g_traceAborted) {
- break;
- }
- } while (nanosleep(&timeLeft, &timeLeft) == -1 && errno == EINTR);
- }
- }
-
- // Stop the trace and restore the default settings.
- stopTrace(isRoot);
-
- if (ok) {
- if (!g_traceAborted) {
- printf(" done\nTRACE:\n");
- fflush(stdout);
- dumpTrace();
- } else {
- printf("\ntrace aborted.\n");
- fflush(stdout);
- }
- clearTrace();
- } else {
- fprintf(stderr, "unable to start tracing\n");
- }
-
- // Reset the trace buffer size to 1.
- setTraceBufferSizeKB(1);
-
- return g_traceAborted ? 1 : 0;
-}
diff --git a/bugmailer/Android.mk b/bugmailer/Android.mk
deleted file mode 100644
index c5aea4ba..00000000
--- a/bugmailer/Android.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2011 The Android Open Source Project
-#
-LOCAL_PATH:= $(call my-dir)
-
-ifeq (platform,$(TARGET_BUILD_JAVA_SUPPORT_LEVEL))
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_MODULE := send_bug
-LOCAL_MODULE_TAGS := optional
-include $(BUILD_JAVA_LIBRARY)
-endif #JAVA_SUPPORT
diff --git a/bugmailer/bugmailer.sh b/bugmailer/bugmailer.sh
deleted file mode 100755
index c467aeea..00000000
--- a/bugmailer/bugmailer.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/system/bin/sh
-
-# TODO: restructure this to keep bugreports entirely on internal storage
-
-# Do not allow bugreports on user builds unless USB debugging
-# is enabled.
-if [ "x$(getprop ro.build.type)" = "xuser" -a \
- "x$(getprop init.svc.adbd)" != "xrunning" ]; then
- exit 0
-fi
-
-# Build emulated storage paths when appropriate
-# See storage config details at http://source.android.com/tech/storage/
-if [ -n "$EMULATED_STORAGE_SOURCE" ]; then
- writePath="$EMULATED_STORAGE_SOURCE/0"
- readPath="$EMULATED_STORAGE_TARGET/0"
-else
- writePath="$EXTERNAL_STORAGE"
- readPath="$EXTERNAL_STORAGE"
-fi
-
-tmpPath="/data/local/tmp"
-bugreportPath="bugreports"
-screenshotPath="Pictures/Screenshots"
-
-# Create directories if needed
-if [ ! -e "$writePath/$bugreportPath" ]; then
- mkdir "$writePath/$bugreportPath"
-fi
-if [ ! -e "$writePath/$screenshotPath" ]; then
- mkdir "$writePath/$screenshotPath"
-fi
-
-timestamp=`date +'%Y-%m-%d-%H-%M-%S'`
-
-# take screen shot
-# we run this as a bg job in case screencap is stuck
-/system/bin/screencap -p "$writePath/$screenshotPath/Screenshot_$timestamp.png" &
-
-# run bugreport
-/system/bin/dumpstate -o "$tmpPath/bugreport-$timestamp" $@
-
-# copy finished bugreport into place for sending
-cp "$tmpPath/bugreport-$timestamp.txt" "$writePath/$bugreportPath/bugreport-$timestamp.txt"
-# clean up any remaining files
-rm $tmpPath/bugreport*
-
-# invoke send_bug to look up email accounts and fire intents
-# make it convenient to send bugreport to oneself
-/system/bin/send_bug "$readPath/$bugreportPath/bugreport-$timestamp.txt" "$readPath/$screenshotPath/Screenshot_$timestamp.png"
diff --git a/bugmailer/send_bug b/bugmailer/send_bug
deleted file mode 100755
index db58b326..00000000
--- a/bugmailer/send_bug
+++ /dev/null
@@ -1,5 +0,0 @@
-# Script to start "send_bug" on the device
-#
-base=/system
-export CLASSPATH=$base/framework/send_bug.jar
-exec app_process $base/bin com.android.commands.sendbug.SendBug "$@"
diff --git a/bugmailer/src/com/android/commands/sendbug/SendBug.java b/bugmailer/src/com/android/commands/sendbug/SendBug.java
deleted file mode 100644
index f47ff9b3..00000000
--- a/bugmailer/src/com/android/commands/sendbug/SendBug.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.commands.sendbug;
-
-import android.accounts.Account;
-import android.accounts.IAccountManager;
-import android.app.ActivityManagerNative;
-import android.app.IActivityManager;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.IPackageManager;
-import android.content.pm.ResolveInfo;
-import android.net.Uri;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.os.SystemProperties;
-import android.os.UserHandle;
-import android.util.Log;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Pattern;
-
-public class SendBug {
-
- private static final String LOG_TAG = SendBug.class.getSimpleName();
- private static final Pattern EMAIL_REGEX = Pattern.compile(
- "^[\\w.%+-]+@[\\w.-]+\\.[a-zA-Z]{2,}$");
- private static final String SEND_BUG_INTENT_ACTION = "android.testing.SEND_BUG";
-
- public static void main(String[] args) {
- if (args.length == 1) {
- new SendBug().run(args[0]);
- } else if (args.length == 2) {
- new SendBug().run(args[0], args[1]);
- }
- }
-
- private void run(String bugreportPath) {
- run(bugreportPath, null);
- }
-
- private void run(String bugreportPath, String screenShotPath) {
- final File bugreport = new File(bugreportPath);
- File screenShot = null;
- if (screenShotPath != null) {
- screenShot = new File(screenShotPath);
- }
- final Uri bugreportUri = Uri.fromFile(bugreport);
- // todo (aalbert): investigate adding a screenshot to BugReporter
- Intent intent = tryBugReporter(bugreportUri);
- if (intent == null) {
- final Uri screenshotUri = screenShot != null
- ? Uri.fromFile(screenShot) : null;
- intent = getSendMailIntent(bugreportUri, screenshotUri);
- }
- if (intent != null) {
- final IActivityManager am = ActivityManagerNative.getDefault();
- if (am == null) {
- Log.e(LOG_TAG, "Cannot get ActivityManager, is the system running?");
- return;
- }
- try {
- am.startActivityAsUser(null, intent, intent.getType(), null, null, 0, 0,
- null, null, null, UserHandle.USER_CURRENT);
- } catch (RemoteException e) {
- // ignore
- }
- } else {
- Log.w(LOG_TAG, "Cannot find account to send bugreport, local path: "
- + bugreportPath);
- }
- }
-
- private Intent tryBugReporter(Uri bugreportUri) {
- final Intent intent = new Intent(SEND_BUG_INTENT_ACTION);
- intent.setData(bugreportUri);
- final IPackageManager pm = IPackageManager.Stub.asInterface(
- ServiceManager.getService("package"));
- if (pm == null) {
- Log.e(LOG_TAG, "Cannot get PackageManager, is the system running?");
- return null;
- }
- final List<ResolveInfo> results;
- try {
- results = pm.queryIntentActivities(intent, null, 0, 0);
- } catch (RemoteException e) {
- return null;
- }
- if (results != null && results.size() > 0) {
- final ResolveInfo info = results.get(0);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setClassName(info.activityInfo.applicationInfo.packageName,
- info.activityInfo.name);
- return intent;
- } else {
- return null;
- }
- }
-
- private Intent getSendMailIntent(Uri bugreportUri, Uri screenshotUri) {
- final Account sendToAccount = findSendToAccount();
- final Intent intent = new Intent(Intent.ACTION_SEND);
- intent.addCategory(Intent.CATEGORY_DEFAULT);
- intent.setType("application/octet-stream");
- intent.putExtra(Intent.EXTRA_SUBJECT, bugreportUri.getLastPathSegment());
- final StringBuilder sb = new StringBuilder();
- sb.append(SystemProperties.get("ro.build.description"));
- sb.append("\n(Sent from BugMailer)");
- intent.putExtra(Intent.EXTRA_TEXT, (CharSequence)sb);
- if (screenshotUri != null) {
- final ArrayList<Uri> attachments = new ArrayList<Uri>();
- attachments.add(bugreportUri);
- attachments.add(screenshotUri);
- intent.setAction(Intent.ACTION_SEND_MULTIPLE);
- intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments);
- } else {
- intent.putExtra(Intent.EXTRA_STREAM, bugreportUri);
- }
- if (sendToAccount != null) {
- intent.putExtra(Intent.EXTRA_EMAIL, new String[]{sendToAccount.name});
- return intent;
- }
- return null;
- }
-
- private Account findSendToAccount() {
- final IAccountManager accountManager = IAccountManager.Stub.asInterface(ServiceManager
- .getService(Context.ACCOUNT_SERVICE));
- if (accountManager == null) {
- Log.e(LOG_TAG, "Cannot get AccountManager, is the system running?");
- return null;
- }
- Account[] accounts = null;
- Account foundAccount = null;
- String preferredDomain = SystemProperties.get("sendbug.preferred.domain");
- if (!preferredDomain.startsWith("@")) {
- preferredDomain = "@" + preferredDomain;
- }
- try {
- accounts = accountManager.getAccounts(null);
- } catch (RemoteException e) {
- // ignore
- }
- if (accounts != null) {
- for (Account account : accounts) {
- if (EMAIL_REGEX.matcher(account.name).matches()) {
- if (!preferredDomain.isEmpty()) {
- // if we have a preferred domain and it matches, return; otherwise keep
- // looking
- if (account.name.endsWith(preferredDomain)) {
- return account;
- } else {
- foundAccount = account;
- }
- // if we don't have a preferred domain, just return since it looks like
- // an email address
- } else {
- return account;
- }
- }
- }
- }
- return foundAccount;
- }
-}
diff --git a/micro_bench/Android.mk b/micro_bench/Android.mk
index 09913ff9..c5be5f7a 100644
--- a/micro_bench/Android.mk
+++ b/micro_bench/Android.mk
@@ -8,3 +8,15 @@ LOCAL_MODULE_TAGS := debug
LOCAL_MODULE := micro_bench
include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := micro_bench.cpp
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := micro_bench_static
+LOCAL_STATIC_LIBRARIES = libc libm
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+
+include $(BUILD_EXECUTABLE)
diff --git a/su/su.c b/su/su.c
index f87f0736..8365379f 100644
--- a/su/su.c
+++ b/su/su.c
@@ -31,18 +31,79 @@
#include <private/android_filesystem_config.h>
+
+void pwtoid(const char *tok, uid_t *uid, gid_t *gid)
+{
+ struct passwd *pw;
+ pw = getpwnam(tok);
+ if (pw) {
+ if (uid) *uid = pw->pw_uid;
+ if (gid) *gid = pw->pw_gid;
+ } else {
+ uid_t tmpid = atoi(tok);
+ if (uid) *uid = tmpid;
+ if (gid) *gid = tmpid;
+ }
+}
+
+void extract_uidgids(const char *uidgids, uid_t *uid, gid_t *gid, gid_t *gids,
+ int *gids_count)
+{
+ char *clobberablegids;
+ char *nexttok;
+ char *tok;
+ int gids_found;
+
+ if (!uidgids || !*uidgids) {
+ *gid = *uid = 0;
+ *gids_count = 0;
+ return;
+ }
+ clobberablegids = strdup(uidgids);
+ strcpy(clobberablegids, uidgids);
+ nexttok = clobberablegids;
+ tok = strsep(&nexttok, ",");
+ pwtoid(tok, uid, gid);
+ tok = strsep(&nexttok, ",");
+ if (!tok) {
+ /* gid is already set above */
+ *gids_count = 0;
+ free(clobberablegids);
+ return;
+ }
+ pwtoid(tok, NULL, gid);
+ gids_found = 0;
+ while ((gids_found < *gids_count) && (tok = strsep(&nexttok, ","))) {
+ pwtoid(tok, NULL, gids);
+ gids_found++;
+ gids++;
+ }
+ if (nexttok && gids_found == *gids_count) {
+ fprintf(stderr, "too many group ids\n");
+ }
+ *gids_count = gids_found;
+ free(clobberablegids);
+}
+
/*
* SU can be given a specific command to exec. UID _must_ be
* specified for this (ie argc => 3).
*
* Usage:
- * su 1000
- * su 1000 ls -l
+ * su 1000
+ * su 1000 ls -l
+ * or
+ * su [uid[,gid[,group1]...] [cmd]]
+ * E.g.
+ * su 1000,shell,net_bw_acct,net_bw_stats id
+ * will return
+ * uid=1000(system) gid=2000(shell) groups=3006(net_bw_stats),3007(net_bw_acct)
*/
int main(int argc, char **argv)
{
struct passwd *pw;
- int uid, gid, myuid;
+ uid_t uid, myuid;
+ gid_t gid, gids[10];
/* Until we have something better, only root and the shell can use su. */
myuid = getuid();
@@ -54,13 +115,13 @@ int main(int argc, char **argv)
if(argc < 2) {
uid = gid = 0;
} else {
- pw = getpwnam(argv[1]);
-
- if(pw == 0) {
- uid = gid = atoi(argv[1]);
- } else {
- uid = pw->pw_uid;
- gid = pw->pw_gid;
+ int gids_count = sizeof(gids)/sizeof(gids[0]);
+ extract_uidgids(argv[1], &uid, &gid, gids, &gids_count);
+ if(gids_count) {
+ if(setgroups(gids_count, gids)) {
+ fprintf(stderr, "su: failed to set groups\n");
+ return 1;
+ }
}
}
@@ -72,9 +133,10 @@ int main(int argc, char **argv)
/* User specified command for exec. */
if (argc == 3 ) {
if (execlp(argv[2], argv[2], NULL) < 0) {
+ int saved_errno = errno;
fprintf(stderr, "su: exec failed for %s Error:%s\n", argv[2],
strerror(errno));
- return -errno;
+ return -saved_errno;
}
} else if (argc > 3) {
/* Copy the rest of the args from main. */
@@ -82,9 +144,10 @@ int main(int argc, char **argv)
memset(exec_args, 0, sizeof(exec_args));
memcpy(exec_args, &argv[2], sizeof(exec_args));
if (execvp(argv[2], exec_args) < 0) {
+ int saved_errno = errno;
fprintf(stderr, "su: exec failed for %s Error:%s\n", argv[2],
strerror(errno));
- return -errno;
+ return -saved_errno;
}
}
diff --git a/tests/binder/benchmarks/Android.mk b/tests/binder/benchmarks/Android.mk
index 15dfe6c5..8680f4da 100644
--- a/tests/binder/benchmarks/Android.mk
+++ b/tests/binder/benchmarks/Android.mk
@@ -27,6 +27,7 @@ LOCAL_STATIC_LIBRARIES += \
LOCAL_SHARED_LIBRARIES += \
libutils \
+ liblog \
libstlport \
libbinder
diff --git a/tests/crypto/Android.mk b/tests/crypto/Android.mk
new file mode 100644
index 00000000..f1500cea
--- /dev/null
+++ b/tests/crypto/Android.mk
@@ -0,0 +1,12 @@
+# Copyright 2013 The Android Open Source Project
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= get_dm_versions.c
+LOCAL_MODULE:= get_dm_versions
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES := $(KERNEL_HEADERS)
+LOCAL_CFLAGS :=
+include $(BUILD_EXECUTABLE)
diff --git a/tests/crypto/get_dm_versions.c b/tests/crypto/get_dm_versions.c
new file mode 100644
index 00000000..6df74918
--- /dev/null
+++ b/tests/crypto/get_dm_versions.c
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <linux/dm-ioctl.h>
+#include <stdlib.h>
+
+#define DM_CRYPT_BUF_SIZE 4096
+
+static void ioctl_init(struct dm_ioctl *io, size_t dataSize, const char *name, unsigned flags)
+{
+ memset(io, 0, dataSize);
+ io->data_size = dataSize;
+ io->data_start = sizeof(struct dm_ioctl);
+ io->version[0] = 4;
+ io->version[1] = 0;
+ io->version[2] = 0;
+ io->flags = flags;
+ if (name) {
+ strncpy(io->name, name, sizeof(io->name));
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ char buffer[DM_CRYPT_BUF_SIZE];
+ struct dm_ioctl *io;
+ struct dm_target_versions *v;
+ int i;
+ int fd;
+
+ fd = open("/dev/device-mapper", O_RDWR);
+ if (fd < 0) {
+ fprintf(stderr, "Cannot open /dev/device-mapper\n");
+ exit(1);
+ }
+
+ io = (struct dm_ioctl *) buffer;
+
+ ioctl_init(io, DM_CRYPT_BUF_SIZE, NULL, 0);
+
+ if (ioctl(fd, DM_LIST_VERSIONS, io)) {
+ fprintf(stderr, "ioctl(DM_LIST_VERSIONS) returned an error\n");
+ exit(1);
+ }
+
+ /* Iterate over the returned versions, and print each subsystem's version */
+ v = (struct dm_target_versions *) &buffer[sizeof(struct dm_ioctl)];
+ while (v->next) {
+ printf("%s: %d.%d.%d\n", v->name, v->version[0], v->version[1], v->version[2]);
+ v = (struct dm_target_versions *)(((char *)v) + v->next);
+ }
+
+ close(fd);
+ exit(0);
+}
+
diff --git a/tests/ext4/Android.mk b/tests/ext4/Android.mk
index 36f2e17d..0c0cdd08 100644
--- a/tests/ext4/Android.mk
+++ b/tests/ext4/Android.mk
@@ -4,7 +4,6 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= corrupt_gdt_free_blocks.c
-
LOCAL_MODULE:= corrupt_gdt_free_blocks
LOCAL_MODULE_TAGS := debug
LOCAL_C_INCLUDES += system/extras/ext4_utils
@@ -15,7 +14,6 @@ include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= set_ext4_err_bit.c
-
LOCAL_MODULE:= set_ext4_err_bit
LOCAL_MODULE_TAGS := debug
@@ -25,7 +23,6 @@ include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= rand_emmc_perf.c
-
LOCAL_MODULE:= rand_emmc_perf
LOCAL_MODULE_TAGS := optional
LOCAL_FORCE_STATIC_EXECUTABLE := true
diff --git a/tests/framebuffer/Android.mk b/tests/framebuffer/Android.mk
index 3ee98281..75a9f75d 100644
--- a/tests/framebuffer/Android.mk
+++ b/tests/framebuffer/Android.mk
@@ -22,11 +22,3 @@ LOCAL_MODULE_TAGS := optional
LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_STATIC_LIBRARIES := libc
include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := mdp_test.c
-LOCAL_MODULE = test-mdp
-LOCAL_MODULE_TAGS := optional
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-LOCAL_STATIC_LIBRARIES := libc
-include $(BUILD_EXECUTABLE)
diff --git a/tests/framebuffer/mdp_test.c b/tests/framebuffer/mdp_test.c
deleted file mode 100644
index 506852fa..00000000
--- a/tests/framebuffer/mdp_test.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Copyright (C) 2007 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include <linux/fb.h>
-#include <linux/msm_mdp.h>
-
-static struct fb_var_screeninfo vi;
-
-static int open_file(char *name, int *fd, int *len, int *fmt)
-{
- struct stat stat;
- char *type, *fn;
-
- type = name;
- fn = strchr(name, ':');
- if (!fn)
- return -1;
- *(fn++) = '\0';
-
- if (!strncmp(type, "yuv420", 6))
- *fmt = MDP_Y_CBCR_H2V2;
- else if (!strncmp(type, "rgb565", 6))
- *fmt = MDP_RGB_565;
- else {
- fprintf(stderr, "Unsupported image type: %s\n", type);
- return -1;
- }
-
- *fd = open(fn, O_RDONLY);
- if (*fd < 0) {
- perror("cannot open file");
- return -1;
- }
-
- if (fstat(*fd, &stat) < 0) {
- perror("cannot fstat file");
- goto err;
- }
-
- *len = stat.st_size;
-
- printf("Successfully opened file %s (fmt=%d len=%d fd=%d)\n", fn, *fmt,
- *len, *fd);
- return 0;
-
-err:
- close(*fd);
- return -1;
-}
-
-static int get_pmem(int *fd, void **data, int sz)
-{
- *fd = open("/dev/pmem", O_RDWR | O_NONBLOCK | O_SYNC);
- if (*fd < 0) {
- perror("cannot open /dev/pmem");
- return -1;
- }
-
- sz = (sz + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
- *data = mmap(NULL, sz, PROT_READ | PROT_WRITE, MAP_SHARED, *fd, 0);
- if (*data == MAP_FAILED) {
- perror("pmem mmap");
- goto err_pmem_mmap;
- }
-
- return 0;
-
-err_pmem_mmap:
- close(*fd);
- return -1;
-}
-
-static int get_framebuffer(int *fd, char **fb, int *width, int *height)
-{
- struct fb_fix_screeninfo fi;
- void *bits;
-
- *fd = open("/dev/graphics/fb0", O_RDWR);
- if(*fd < 0) {
- perror("cannot open fb0");
- return -1;
- }
-
- if(ioctl(*fd, FBIOGET_FSCREENINFO, &fi) < 0) {
- perror("failed to get fb0 info");
- return -1;
- }
-
- if(ioctl(*fd, FBIOGET_VSCREENINFO, &vi) < 0) {
- perror("failed to get fb0 info");
- return -1;
- }
-
- bits = mmap(0, fi.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, *fd, 0);
- if(bits == MAP_FAILED) {
- perror("failed to mmap framebuffer");
- return -1;
- }
-
- *width = vi.xres;
- *height = vi.yres;
- *fb = bits;
- return 0;
-}
-
-static void set_active_framebuffer(int fd, unsigned n)
-{
-
- if(n > 1) return;
- vi.yres_virtual = vi.yres * 2;
- vi.yoffset = n * vi.yres;
- if(ioctl(fd, FBIOPUT_VSCREENINFO, &vi) < 0) {
- fprintf(stderr,"active fb swap failed!\n");
- }
-}
-
-/* geometry: WxH+X+Y */
-int parse_geometry(char *geom, int *w, int *h, int *x, int *y)
-{
- char *ptr;
-
- *w = *h = 0;
-
- if (!(ptr = strchr(geom, 'x')))
- return -1;
- *ptr = '\0';
- *w = atoi(geom);
- geom = ptr + 1;
-
- ptr = strchr(geom, '+');
- if (ptr)
- *ptr = '\0';
- *h = atoi(geom);
- if (!ptr)
- return 0;
-
- geom = ptr + 1;
-
- if (!x || !y || !(ptr = strchr(geom, '+')))
- return -1;
- *ptr = '\0';
- *x = atoi(geom);
- geom = ptr + 1;
-
- *y = atoi(geom);
-
- return 0;
-}
-
-int main(int argc, const char *argv[])
-{
- int fb_fd, width, height;
- char* fb;
- struct mdp_blit_req_list *req_list;
- struct mdp_blit_req *req;
- int opt;
- int srcw = 0, srch = 0, dstw = 0, dsth = 0;
- int srcx = 0; int srcy = 0;
- int dstx = 10; int dsty = 10;
- int src_imgw = 0, src_imgh = 0, dst_imgw = 0, dst_imgh = 0;
- int from;
- int src_fmt;
- int dst_fmt = MDP_RGB_565;
- int src_fd = -1;
- void *src_data;
-
- req_list = malloc(sizeof(struct mdp_blit_req_list) +
- sizeof(struct mdp_blit_req));
- req_list->count = 1;
- req = req_list->req;
-
-
- while ((opt = getopt(argc, argv, "s:d:f:t:u:v:")) != -1) {
- switch (opt) {
- case 's':
- if (parse_geometry(optarg, &srcw, &srch, &srcx, &srcy)) {
- fprintf(stderr, "Can't parse source\n");
- exit(-1);
- }
- printf("Got source: w=%d h=%d x=%d y=%d\n", srcw, srch, srcx, srcy);
- break;
-
- case 'd':
- if (parse_geometry(optarg, &dstw, &dsth, &dstx, &dsty)) {
- fprintf(stderr, "Can't parse dest\n");
- exit(-1);
- }
- printf("Got dest: w=%d h=%d x=%d y=%d\n", dstw, dsth, dstx, dsty);
- break;
-
- case 'u':
- if (parse_geometry(optarg, &src_imgw, &src_imgh, NULL, NULL)) {
- fprintf(stderr, "Can't parse src image size\n");
- exit(-1);
- }
- printf("Got src img sz: w=%d h=%d\n", src_imgw, src_imgh);
- break;
-
- case 'v':
- if (parse_geometry(optarg, &dst_imgw, &dst_imgh, NULL, NULL)) {
- fprintf(stderr, "Can't parse dst image size\n");
- exit(-1);
- }
- printf("Got dst img sz: w=%d h=%d\n", dst_imgw, dst_imgh);
- break;
-
- case 'f':
- {
- int file_fd;
- int file_len;
- int bytes;
- void *ptr;
- if (open_file(optarg, &file_fd, &file_len, &src_fmt) < 0) {
- fprintf(stderr, "Can't open source file\n");
- exit(-1);
- }
-
- if (get_pmem(&src_fd, &src_data, file_len) < 0) {
- close(file_fd);
- exit(-1);
- }
-
- ptr = src_data;
- while (file_len) {
- bytes = read(file_fd, ptr, file_len);
- if (bytes < 0) {
- perror("Could not read data from file");
- exit(-1);
- }
- file_len -= bytes;
- ptr += bytes;
- }
- }
- break;
-
- case 't':
- if (!strncmp(optarg, "yuv420", 6))
- dst_fmt = MDP_Y_CBCR_H2V2;
-#if 0
- else if (!strncmp(optarg, "rgb565", 6))
- dst_fmt = MDP_RGB_565;
-#endif
- break;
-
- default:
- fprintf(stderr, "Usage: %s -s source -d dest\n", argv[0]);
- exit(-1);
- }
- }
-
- if (get_framebuffer(&fb_fd, &fb, &width, &height)) {
- printf("couldnt' get fb\n");
- return -1;
- }
-
- set_active_framebuffer(fb_fd, 0);
-
- if (!src_imgw || !src_imgh) {
- src_imgw = width;
- src_imgh = height;
- }
-
- if (!dst_imgw || !dst_imgh) {
- dst_imgw = width;
- dst_imgh = height;
- }
-
- if (src_fd < 0) {
- src_fd = fb_fd;
- src_fmt = MDP_RGB_565;
- }
-
- req->src.width = src_imgw;
- req->src.height = src_imgh;
- req->src.format = src_fmt;
- req->src.offset = 0;
- req->src.memory_id = src_fd;
- req->src_rect.x = srcx;
- req->src_rect.y = srcy;
- req->src_rect.w = srcw;
- req->src_rect.h = srch;
-
- req->dst.width = dst_imgw;
- req->dst.height = dst_imgh;
- req->dst.format = dst_fmt;
- req->dst.offset = 0;
- req->dst.memory_id = fb_fd;
- req->dst_rect.x = dstx;
- req->dst_rect.y = dsty;
- req->dst_rect.w = dstw;
- req->dst_rect.h = dsth;
- req->alpha = MDP_ALPHA_NOP;
- req->transp_mask = MDP_TRANSP_NOP;
-// req->flags = MDP_ROT_90;
- req->flags = MDP_ROT_NOP;
-
- if(ioctl(fb_fd, MSMFB_BLIT, req_list))
- fprintf(stderr, "crap, failed blit\n");
-
- printf("Done\n");
- return 0;
-}
diff --git a/tests/iptables/qtaguid/Android.mk b/tests/iptables/qtaguid/Android.mk
index cf0a2ba2..a6616785 100644
--- a/tests/iptables/qtaguid/Android.mk
+++ b/tests/iptables/qtaguid/Android.mk
@@ -20,7 +20,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := tests
LOCAL_MODULE := socketTag
LOCAL_SRC_FILES := socketTag.cpp
-LOCAL_SHARED_LIBRARIES += libcutils libutils
+LOCAL_SHARED_LIBRARIES += libcutils libutils liblog
LOCAL_STATIC_LIBRARIES += libtestUtil
LOCAL_C_INCLUDES += system/extras/tests/include
diff --git a/tests/storage/Android.mk b/tests/storage/Android.mk
new file mode 100644
index 00000000..462ebef6
--- /dev/null
+++ b/tests/storage/Android.mk
@@ -0,0 +1,17 @@
+# Copyright 2013 The Android Open Source Project
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := opentest.c
+LOCAL_MODULE := opentest
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := wipe_blkdev.c
+LOCAL_MODULE := wipe_blkdev
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_EXECUTABLE)
+
diff --git a/tests/storage/opentest.c b/tests/storage/opentest.c
new file mode 100644
index 00000000..05d55869
--- /dev/null
+++ b/tests/storage/opentest.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+int main(int argc, char *argv[])
+{
+ int i;
+ int nfiles;
+ int *fds;
+ char *dir;
+ struct stat statbuf;
+ char name[16];
+ struct rlimit rlim;
+
+ if (argc != 3) {
+ fprintf(stderr, "Usage: opentest <directory> <num_files>\n");
+ exit(1);
+ }
+
+ dir = argv[1];
+
+ nfiles = atoi(argv[2]);
+ if ((nfiles <= 0) || (nfiles > 65536)) {
+ fprintf(stderr, "num_files must be between 1 and 65536\n");
+ exit(1);
+ }
+
+ if (stat(dir, &statbuf)) {
+ fprintf(stderr, "Cannot stat %s\n", dir);
+ exit(1);
+ }
+
+ if (! S_ISDIR(statbuf.st_mode)) {
+ fprintf(stderr, "%s is not a directory!\n", dir);
+ exit(1);
+ }
+
+ if (access(dir, R_OK | W_OK)) {
+ fprintf(stderr, "No access to %s\n", dir);
+ exit(1);
+ }
+
+ fds = malloc(nfiles * sizeof(int));
+ if (fds == 0) {
+ fprintf(stderr, "Unable to malloc array of %d fds\n", nfiles);
+ exit(1);
+ }
+
+ if (chdir(dir)) {
+ fprintf(stderr, "Cannot chdir to %s\n", dir);
+ exit(1);
+ }
+
+ rlim.rlim_cur = nfiles + 10;
+ rlim.rlim_max = nfiles + 10;
+ if (setrlimit(RLIMIT_NOFILE, &rlim)) {
+ fprintf(stderr, "Unable to raise RLIMIT_NOFILE to %ld\n", rlim.rlim_cur);
+ exit(1);
+ }
+
+ for (i = 0; i < nfiles; i++) {
+ snprintf(name, sizeof(name), "%d", i);
+ fds[i] = open(name, O_WRONLY | O_CREAT, 0666);
+ if (fds[i] < 0) {
+ fprintf(stderr, "Unable to open %d fd\n", i);
+ exit(1);
+ }
+ }
+
+ /* Rely upon exit to cleanup! */
+ exit(0);
+}
+
+
diff --git a/tests/storage/wipe_blkdev.c b/tests/storage/wipe_blkdev.c
new file mode 100644
index 00000000..43b630b9
--- /dev/null
+++ b/tests/storage/wipe_blkdev.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2011, 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+#include <errno.h>
+
+typedef unsigned long long u64;
+
+#ifndef BLKDISCARD
+#define BLKDISCARD _IO(0x12,119)
+#endif
+
+#ifndef BLKSECDISCARD
+#define BLKSECDISCARD _IO(0x12,125)
+#endif
+
+static u64 get_block_device_size(int fd)
+{
+ u64 size = 0;
+ int ret;
+
+ ret = ioctl(fd, BLKGETSIZE64, &size);
+
+ if (ret)
+ return 0;
+
+ return size;
+}
+
+static int wipe_block_device(int fd, u64 len, int secure)
+{
+ u64 range[2];
+ int ret;
+ int req;
+
+ range[0] = 0;
+ range[1] = len;
+ if (secure) {
+ req = BLKSECDISCARD;
+ } else {
+ req = BLKDISCARD;
+ }
+
+ ret = ioctl(fd, req, &range);
+ if (ret < 0) {
+ fprintf(stderr, "%s discard failed, errno = %d\n",
+ secure ? "Secure" : "Nonsecure", errno);
+ }
+
+ return ret;
+}
+
+static void usage(void)
+{
+ fprintf(stderr, "Usage: wipe_blkdev [-s] <partition>\n");
+ exit(1);
+}
+
+int main(int argc, char *argv[])
+{
+ int secure = 0;
+ char *devname;
+ int fd;
+ u64 len;
+ struct stat statbuf;
+ int ret;
+
+ if ((argc != 2) && (argc != 3)) {
+ usage();
+ }
+
+ if (argc == 3) {
+ if (!strcmp(argv[1], "-s")) {
+ secure = 1;
+ devname = argv[2];
+ } else {
+ usage();
+ }
+ } else {
+ devname = argv[1];
+ }
+
+ fd = open(devname, O_RDWR);
+ if (fd < 0) {
+ fprintf(stderr, "Cannot open device %s\n", devname);
+ exit(1);
+ }
+
+ if (fstat(fd, &statbuf) < 0) {
+ fprintf(stderr, "Cannot stat %s\n", devname);
+ exit(1);
+ }
+
+ if (!S_ISBLK(statbuf.st_mode)) {
+ fprintf(stderr, "%s is not a block device\n", devname);
+ exit(1);
+ }
+
+ len = get_block_device_size(fd);
+
+ if (! len) {
+ fprintf(stderr, "Cannot get size of block device %s\n", devname);
+ exit(1);
+ }
+
+ ret = wipe_block_device(fd, len, secure);
+
+ close(fd);
+
+ return ret;
+}
diff --git a/tests/wifi/stress/Android.mk b/tests/wifi/stress/Android.mk
index e9a7cc45..65dfc1ae 100644
--- a/tests/wifi/stress/Android.mk
+++ b/tests/wifi/stress/Android.mk
@@ -21,7 +21,7 @@ LOCAL_MODULE_TAGS := tests
LOCAL_MODULE := wifiLoadScanAssoc
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativestresstest
LOCAL_SRC_FILES := wifiLoadScanAssoc.c
-LOCAL_SHARED_LIBRARIES += libcutils libutils libhardware_legacy
+LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libhardware_legacy
LOCAL_STATIC_LIBRARIES += libtestUtil
LOCAL_C_INCLUDES += system/extras/tests/include \
hardware/libhardware_legacy/include