Anders Lewis | a7b0f88 | 2017-07-24 20:01:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <fcntl.h> |
| 18 | #include <stdio.h> |
| 19 | #include <sys/types.h> |
| 20 | #include <sys/wait.h> |
| 21 | #include <unistd.h> |
| 22 | |
| 23 | #include <regex> |
| 24 | #include <string> |
| 25 | #include <vector> |
| 26 | |
| 27 | #include <gtest/gtest.h> |
| 28 | |
| 29 | class SystemTests : public ::testing::Test { |
| 30 | protected: |
| 31 | void SetUp() override { |
| 32 | raw_output_ = ""; |
| 33 | sanitized_output_ = ""; |
| 34 | exitcode_ = 0; |
| 35 | } |
| 36 | |
| 37 | void SanitizeOutput(); |
| 38 | |
| 39 | void Exec(std::vector<const char*> args); |
| 40 | void ExecAndCapture(std::vector<const char*> args); |
| 41 | void RunTest(std::vector<const char*> extra_args = {}); |
| 42 | void Verify(const std::string& expected_output, int expected_exitcode, |
| 43 | std::vector<const char*> extra_args = {}); |
| 44 | |
| 45 | std::string raw_output_; |
| 46 | std::string sanitized_output_; |
| 47 | int exitcode_; |
| 48 | pid_t pid_; |
| 49 | int fd_; |
| 50 | }; |
| 51 | |
| 52 | void SystemTests::SanitizeOutput() { |
| 53 | // Cut off anything after the arguments, since that varies with time. |
| 54 | sanitized_output_ = std::regex_replace(raw_output_, std::regex(".+(BM_\\S+) +.+"), "$1"); |
| 55 | |
| 56 | // Remove everything before the header. |
| 57 | sanitized_output_.erase(0, sanitized_output_.find("------------------------------------------------")); |
| 58 | |
| 59 | // Remove the header. |
| 60 | sanitized_output_.erase(0, sanitized_output_.find("BM_")); |
| 61 | |
| 62 | // Remove any hanging output. |
| 63 | sanitized_output_.erase(sanitized_output_.find_last_of("BM_\\S+\n") + 1); |
| 64 | } |
| 65 | |
| 66 | static void GetExe(std::string* exe_name) { |
| 67 | char path[PATH_MAX]; |
| 68 | ssize_t path_len = readlink("/proc/self/exe", path, sizeof(path)); |
| 69 | ASSERT_TRUE(path_len >= 0); |
| 70 | *exe_name = std::string(std::regex_replace(path, std::regex("-tests"), "")); |
| 71 | } |
| 72 | |
| 73 | void SystemTests::Exec(std::vector<const char*> args) { |
| 74 | int fds[2]; |
| 75 | ASSERT_NE(-1, pipe(fds)); |
| 76 | ASSERT_NE(-1, fcntl(fds[0], F_SETFL, O_NONBLOCK)); |
| 77 | |
| 78 | if ((pid_ = fork()) == 0) { |
| 79 | // Run the test. |
| 80 | close(fds[0]); |
| 81 | close(STDIN_FILENO); |
| 82 | close(STDOUT_FILENO); |
| 83 | close(STDERR_FILENO); |
| 84 | ASSERT_NE(0, dup2(fds[1], STDOUT_FILENO)); |
| 85 | ASSERT_NE(0, dup2(fds[1], STDERR_FILENO)); |
| 86 | close(fds[1]); |
| 87 | |
| 88 | std::string exe_name; |
| 89 | GetExe(&exe_name); |
| 90 | args.insert(args.begin(), exe_name.c_str()); |
| 91 | args.push_back(nullptr); |
| 92 | execv(args[0], reinterpret_cast<char* const*>(const_cast<char**>(args.data()))); |
| 93 | exit(1); |
| 94 | } |
| 95 | ASSERT_NE(-1, pid_); |
| 96 | |
| 97 | close(fds[1]); |
| 98 | fd_ = fds[0]; |
| 99 | } |
| 100 | |
| 101 | void SystemTests::Verify(const std::string& expected_output, |
| 102 | int expected_exitcode, std::vector<const char*> extra_args) { |
| 103 | std::vector<const char*> args; |
| 104 | for (const auto& arg : extra_args) { |
| 105 | args.push_back(arg); |
| 106 | } |
| 107 | |
| 108 | Exec(args); |
| 109 | |
| 110 | raw_output_ = ""; |
| 111 | while (true) { |
| 112 | char buffer[4097]; |
| 113 | ssize_t bytes = TEMP_FAILURE_RETRY(read(fd_, buffer, sizeof(buffer) - 1)); |
| 114 | if (bytes == -1 && errno == EAGAIN) { |
| 115 | continue; |
| 116 | } |
| 117 | ASSERT_NE(-1, bytes); |
| 118 | if (bytes == 0) { |
| 119 | break; |
| 120 | } |
| 121 | buffer[bytes] = '\0'; |
| 122 | raw_output_ += buffer; |
| 123 | } |
| 124 | close(fd_); |
| 125 | |
| 126 | int status; |
| 127 | ASSERT_EQ(pid_, TEMP_FAILURE_RETRY(waitpid(pid_, &status, 0))) << "Test output:\n" << raw_output_; |
| 128 | exitcode_ = WEXITSTATUS(status); |
| 129 | SanitizeOutput(); |
| 130 | |
| 131 | ASSERT_EQ(expected_exitcode, exitcode_) << "Test output:\n" << raw_output_; |
| 132 | if (!expected_output.empty()) { |
| 133 | ASSERT_EQ(expected_output, sanitized_output_); |
| 134 | } |
| 135 | |
| 136 | } |
| 137 | |
| 138 | TEST_F(SystemTests, full_suite) { |
| 139 | std::string expected = |
| 140 | "BM_empty/iterations:1\n" |
| 141 | "BM_load_relaxed/iterations:1\n" |
| 142 | "BM_load_acquire/iterations:1\n" |
| 143 | "BM_store_release/iterations:1\n" |
| 144 | "BM_store_seq_cst/iterations:1\n" |
| 145 | "BM_fetch_add_relaxed/iterations:1\n" |
| 146 | "BM_fetch_add_seq_cst/iterations:1\n" |
| 147 | "BM_acquire_fence/iterations:1\n" |
| 148 | "BM_seq_cst_fence/iterations:1\n" |
| 149 | "BM_fetch_add_cs/iterations:1\n" |
| 150 | "BM_math_sqrt/iterations:1\n" |
| 151 | "BM_math_log10/iterations:1\n" |
| 152 | "BM_math_logb/iterations:1\n" |
| 153 | "BM_math_isfinite_macro/0/iterations:1\n" |
| 154 | "BM_math_isfinite/0/iterations:1\n" |
| 155 | "BM_math_isinf_macro/0/iterations:1\n" |
| 156 | "BM_math_isinf/0/iterations:1\n" |
| 157 | "BM_math_isnan_macro/0/iterations:1\n" |
| 158 | "BM_math_isnan/0/iterations:1\n" |
| 159 | "BM_math_isnormal_macro/0/iterations:1\n" |
| 160 | "BM_math_isnormal/0/iterations:1\n" |
| 161 | "BM_math_sin_fast/iterations:1\n" |
| 162 | "BM_math_sin_feupdateenv/iterations:1\n" |
| 163 | "BM_math_sin_fesetenv/iterations:1\n" |
| 164 | "BM_math_fpclassify/0/iterations:1\n" |
| 165 | "BM_math_signbit_macro/0/iterations:1\n" |
| 166 | "BM_math_signbit/0/iterations:1\n" |
| 167 | "BM_math_fabs_macro/0/iterations:1\n" |
| 168 | "BM_math_fabs/0/iterations:1\n" |
| 169 | "BM_property_get/1/iterations:1\n" |
| 170 | "BM_property_get/4/iterations:1\n" |
| 171 | "BM_property_get/16/iterations:1\n" |
| 172 | "BM_property_get/64/iterations:1\n" |
| 173 | "BM_property_get/128/iterations:1\n" |
| 174 | "BM_property_get/256/iterations:1\n" |
| 175 | "BM_property_get/512/iterations:1\n" |
| 176 | "BM_property_find/1/iterations:1\n" |
| 177 | "BM_property_find/4/iterations:1\n" |
| 178 | "BM_property_find/16/iterations:1\n" |
| 179 | "BM_property_find/64/iterations:1\n" |
| 180 | "BM_property_find/128/iterations:1\n" |
| 181 | "BM_property_find/256/iterations:1\n" |
| 182 | "BM_property_find/512/iterations:1\n" |
| 183 | "BM_property_read/1/iterations:1\n" |
| 184 | "BM_property_read/4/iterations:1\n" |
| 185 | "BM_property_read/16/iterations:1\n" |
| 186 | "BM_property_read/64/iterations:1\n" |
| 187 | "BM_property_read/128/iterations:1\n" |
| 188 | "BM_property_read/256/iterations:1\n" |
| 189 | "BM_property_read/512/iterations:1\n" |
| 190 | "BM_property_serial/1/iterations:1\n" |
| 191 | "BM_property_serial/4/iterations:1\n" |
| 192 | "BM_property_serial/16/iterations:1\n" |
| 193 | "BM_property_serial/64/iterations:1\n" |
| 194 | "BM_property_serial/128/iterations:1\n" |
| 195 | "BM_property_serial/256/iterations:1\n" |
| 196 | "BM_property_serial/512/iterations:1\n" |
| 197 | "BM_pthread_self/iterations:1\n" |
| 198 | "BM_pthread_getspecific/iterations:1\n" |
| 199 | "BM_pthread_setspecific/iterations:1\n" |
| 200 | "BM_pthread_once/iterations:1\n" |
| 201 | "BM_pthread_mutex_lock/iterations:1\n" |
| 202 | "BM_pthread_mutex_lock_ERRORCHECK/iterations:1\n" |
| 203 | "BM_pthread_mutex_lock_RECURSIVE/iterations:1\n" |
| 204 | "BM_pthread_rwlock_read/iterations:1\n" |
| 205 | "BM_pthread_rwlock_write/iterations:1\n" |
| 206 | "BM_pthread_create/iterations:1\n" |
| 207 | "BM_pthread_create_and_run/iterations:1\n" |
| 208 | "BM_pthread_exit_and_join/iterations:1\n" |
| 209 | "BM_pthread_key_create/iterations:1\n" |
| 210 | "BM_pthread_key_delete/iterations:1\n" |
| 211 | "BM_semaphore_sem_getvalue/iterations:1\n" |
| 212 | "BM_semaphore_sem_wait_sem_post/iterations:1\n" |
| 213 | "BM_stdio_fread/8/iterations:1\n" |
| 214 | "BM_stdio_fread/64/iterations:1\n" |
| 215 | "BM_stdio_fread/512/iterations:1\n" |
| 216 | "BM_stdio_fread/1024/iterations:1\n" |
| 217 | "BM_stdio_fread/8192/iterations:1\n" |
| 218 | "BM_stdio_fread/16384/iterations:1\n" |
| 219 | "BM_stdio_fread/32768/iterations:1\n" |
| 220 | "BM_stdio_fread/65536/iterations:1\n" |
| 221 | "BM_stdio_fwrite/8/iterations:1\n" |
| 222 | "BM_stdio_fwrite/64/iterations:1\n" |
| 223 | "BM_stdio_fwrite/512/iterations:1\n" |
| 224 | "BM_stdio_fwrite/1024/iterations:1\n" |
| 225 | "BM_stdio_fwrite/8192/iterations:1\n" |
| 226 | "BM_stdio_fwrite/16384/iterations:1\n" |
| 227 | "BM_stdio_fwrite/32768/iterations:1\n" |
| 228 | "BM_stdio_fwrite/65536/iterations:1\n" |
| 229 | "BM_stdio_fread_unbuffered/8/iterations:1\n" |
| 230 | "BM_stdio_fread_unbuffered/64/iterations:1\n" |
| 231 | "BM_stdio_fread_unbuffered/512/iterations:1\n" |
| 232 | "BM_stdio_fread_unbuffered/1024/iterations:1\n" |
| 233 | "BM_stdio_fread_unbuffered/8192/iterations:1\n" |
| 234 | "BM_stdio_fread_unbuffered/16384/iterations:1\n" |
| 235 | "BM_stdio_fread_unbuffered/32768/iterations:1\n" |
| 236 | "BM_stdio_fread_unbuffered/65536/iterations:1\n" |
| 237 | "BM_stdio_fwrite_unbuffered/8/iterations:1\n" |
| 238 | "BM_stdio_fwrite_unbuffered/64/iterations:1\n" |
| 239 | "BM_stdio_fwrite_unbuffered/512/iterations:1\n" |
| 240 | "BM_stdio_fwrite_unbuffered/1024/iterations:1\n" |
| 241 | "BM_stdio_fwrite_unbuffered/8192/iterations:1\n" |
| 242 | "BM_stdio_fwrite_unbuffered/16384/iterations:1\n" |
| 243 | "BM_stdio_fwrite_unbuffered/32768/iterations:1\n" |
| 244 | "BM_stdio_fwrite_unbuffered/65536/iterations:1\n" |
Anders Lewis | ac4f4b4 | 2017-08-08 18:29:51 -0700 | [diff] [blame] | 245 | "BM_stdio_fopen_fgets_fclose_locking/1024/iterations:1\n" |
| 246 | "BM_stdio_fopen_fgets_fclose_no_locking/1024/iterations:1\n" |
| 247 | "BM_stdio_fopen_fgetc_fclose_locking/1024/iterations:1\n" |
| 248 | "BM_stdio_fopen_fgetc_fclose_no_locking/1024/iterations:1\n" |
Anders Lewis | a7b0f88 | 2017-07-24 20:01:13 -0700 | [diff] [blame] | 249 | "BM_string_memcmp/8/0/0/iterations:1\n" |
| 250 | "BM_string_memcmp/64/0/0/iterations:1\n" |
| 251 | "BM_string_memcmp/512/0/0/iterations:1\n" |
| 252 | "BM_string_memcmp/1024/0/0/iterations:1\n" |
| 253 | "BM_string_memcmp/8192/0/0/iterations:1\n" |
| 254 | "BM_string_memcmp/16384/0/0/iterations:1\n" |
| 255 | "BM_string_memcmp/32768/0/0/iterations:1\n" |
| 256 | "BM_string_memcmp/65536/0/0/iterations:1\n" |
| 257 | "BM_string_memcpy/8/0/0/iterations:1\n" |
| 258 | "BM_string_memcpy/64/0/0/iterations:1\n" |
| 259 | "BM_string_memcpy/512/0/0/iterations:1\n" |
| 260 | "BM_string_memcpy/1024/0/0/iterations:1\n" |
| 261 | "BM_string_memcpy/8192/0/0/iterations:1\n" |
| 262 | "BM_string_memcpy/16384/0/0/iterations:1\n" |
| 263 | "BM_string_memcpy/32768/0/0/iterations:1\n" |
| 264 | "BM_string_memcpy/65536/0/0/iterations:1\n" |
| 265 | "BM_string_memmove_non_overlapping/8/0/iterations:1\n" |
| 266 | "BM_string_memmove_non_overlapping/64/0/iterations:1\n" |
| 267 | "BM_string_memmove_non_overlapping/512/0/iterations:1\n" |
| 268 | "BM_string_memmove_non_overlapping/1024/0/iterations:1\n" |
| 269 | "BM_string_memmove_non_overlapping/8192/0/iterations:1\n" |
| 270 | "BM_string_memmove_non_overlapping/16384/0/iterations:1\n" |
| 271 | "BM_string_memmove_non_overlapping/32768/0/iterations:1\n" |
| 272 | "BM_string_memmove_non_overlapping/65536/0/iterations:1\n" |
| 273 | "BM_string_memmove_overlap_dst_before_src/8/0/iterations:1\n" |
| 274 | "BM_string_memmove_overlap_dst_before_src/64/0/iterations:1\n" |
| 275 | "BM_string_memmove_overlap_dst_before_src/512/0/iterations:1\n" |
| 276 | "BM_string_memmove_overlap_dst_before_src/1024/0/iterations:1\n" |
| 277 | "BM_string_memmove_overlap_dst_before_src/8192/0/iterations:1\n" |
| 278 | "BM_string_memmove_overlap_dst_before_src/16384/0/iterations:1\n" |
| 279 | "BM_string_memmove_overlap_dst_before_src/32768/0/iterations:1\n" |
| 280 | "BM_string_memmove_overlap_dst_before_src/65536/0/iterations:1\n" |
| 281 | "BM_string_memmove_overlap_src_before_dst/8/0/iterations:1\n" |
| 282 | "BM_string_memmove_overlap_src_before_dst/64/0/iterations:1\n" |
| 283 | "BM_string_memmove_overlap_src_before_dst/512/0/iterations:1\n" |
| 284 | "BM_string_memmove_overlap_src_before_dst/1024/0/iterations:1\n" |
| 285 | "BM_string_memmove_overlap_src_before_dst/8192/0/iterations:1\n" |
| 286 | "BM_string_memmove_overlap_src_before_dst/16384/0/iterations:1\n" |
| 287 | "BM_string_memmove_overlap_src_before_dst/32768/0/iterations:1\n" |
| 288 | "BM_string_memmove_overlap_src_before_dst/65536/0/iterations:1\n" |
| 289 | "BM_string_memset/8/0/iterations:1\n" |
| 290 | "BM_string_memset/64/0/iterations:1\n" |
| 291 | "BM_string_memset/512/0/iterations:1\n" |
| 292 | "BM_string_memset/1024/0/iterations:1\n" |
| 293 | "BM_string_memset/8192/0/iterations:1\n" |
| 294 | "BM_string_memset/16384/0/iterations:1\n" |
| 295 | "BM_string_memset/32768/0/iterations:1\n" |
| 296 | "BM_string_memset/65536/0/iterations:1\n" |
| 297 | "BM_string_strlen/8/0/iterations:1\n" |
| 298 | "BM_string_strlen/64/0/iterations:1\n" |
| 299 | "BM_string_strlen/512/0/iterations:1\n" |
| 300 | "BM_string_strlen/1024/0/iterations:1\n" |
| 301 | "BM_string_strlen/8192/0/iterations:1\n" |
| 302 | "BM_string_strlen/16384/0/iterations:1\n" |
| 303 | "BM_string_strlen/32768/0/iterations:1\n" |
| 304 | "BM_string_strlen/65536/0/iterations:1\n" |
| 305 | "BM_string_strcat_copy_only/8/0/0/iterations:1\n" |
| 306 | "BM_string_strcat_copy_only/64/0/0/iterations:1\n" |
| 307 | "BM_string_strcat_copy_only/512/0/0/iterations:1\n" |
| 308 | "BM_string_strcat_copy_only/1024/0/0/iterations:1\n" |
| 309 | "BM_string_strcat_copy_only/8192/0/0/iterations:1\n" |
| 310 | "BM_string_strcat_copy_only/16384/0/0/iterations:1\n" |
| 311 | "BM_string_strcat_copy_only/32768/0/0/iterations:1\n" |
| 312 | "BM_string_strcat_copy_only/65536/0/0/iterations:1\n" |
| 313 | "BM_string_strcat_seek_only/8/0/0/iterations:1\n" |
| 314 | "BM_string_strcat_seek_only/64/0/0/iterations:1\n" |
| 315 | "BM_string_strcat_seek_only/512/0/0/iterations:1\n" |
| 316 | "BM_string_strcat_seek_only/1024/0/0/iterations:1\n" |
| 317 | "BM_string_strcat_seek_only/8192/0/0/iterations:1\n" |
| 318 | "BM_string_strcat_seek_only/16384/0/0/iterations:1\n" |
| 319 | "BM_string_strcat_seek_only/32768/0/0/iterations:1\n" |
| 320 | "BM_string_strcat_seek_only/65536/0/0/iterations:1\n" |
| 321 | "BM_string_strcat_half_copy_half_seek/8/0/0/iterations:1\n" |
| 322 | "BM_string_strcat_half_copy_half_seek/64/0/0/iterations:1\n" |
| 323 | "BM_string_strcat_half_copy_half_seek/512/0/0/iterations:1\n" |
| 324 | "BM_string_strcat_half_copy_half_seek/1024/0/0/iterations:1\n" |
| 325 | "BM_string_strcat_half_copy_half_seek/8192/0/0/iterations:1\n" |
| 326 | "BM_string_strcat_half_copy_half_seek/16384/0/0/iterations:1\n" |
| 327 | "BM_string_strcat_half_copy_half_seek/32768/0/0/iterations:1\n" |
| 328 | "BM_string_strcat_half_copy_half_seek/65536/0/0/iterations:1\n" |
| 329 | "BM_string_strcpy/8/0/0/iterations:1\n" |
| 330 | "BM_string_strcpy/64/0/0/iterations:1\n" |
| 331 | "BM_string_strcpy/512/0/0/iterations:1\n" |
| 332 | "BM_string_strcpy/1024/0/0/iterations:1\n" |
| 333 | "BM_string_strcpy/8192/0/0/iterations:1\n" |
| 334 | "BM_string_strcpy/16384/0/0/iterations:1\n" |
| 335 | "BM_string_strcpy/32768/0/0/iterations:1\n" |
| 336 | "BM_string_strcpy/65536/0/0/iterations:1\n" |
| 337 | "BM_string_strcmp/8/0/0/iterations:1\n" |
| 338 | "BM_string_strcmp/64/0/0/iterations:1\n" |
| 339 | "BM_string_strcmp/512/0/0/iterations:1\n" |
| 340 | "BM_string_strcmp/1024/0/0/iterations:1\n" |
| 341 | "BM_string_strcmp/8192/0/0/iterations:1\n" |
| 342 | "BM_string_strcmp/16384/0/0/iterations:1\n" |
| 343 | "BM_string_strcmp/32768/0/0/iterations:1\n" |
| 344 | "BM_string_strcmp/65536/0/0/iterations:1\n" |
Anders Lewis | ac4f4b4 | 2017-08-08 18:29:51 -0700 | [diff] [blame] | 345 | "BM_string_strstr/8/0/0/iterations:1\n" |
| 346 | "BM_string_strstr/64/0/0/iterations:1\n" |
| 347 | "BM_string_strstr/512/0/0/iterations:1\n" |
| 348 | "BM_string_strstr/1024/0/0/iterations:1\n" |
| 349 | "BM_string_strstr/8192/0/0/iterations:1\n" |
| 350 | "BM_string_strstr/16384/0/0/iterations:1\n" |
| 351 | "BM_string_strstr/32768/0/0/iterations:1\n" |
| 352 | "BM_string_strstr/65536/0/0/iterations:1\n" |
| 353 | "BM_string_strchr/8/0/iterations:1\n" |
| 354 | "BM_string_strchr/64/0/iterations:1\n" |
| 355 | "BM_string_strchr/512/0/iterations:1\n" |
| 356 | "BM_string_strchr/1024/0/iterations:1\n" |
| 357 | "BM_string_strchr/8192/0/iterations:1\n" |
| 358 | "BM_string_strchr/16384/0/iterations:1\n" |
| 359 | "BM_string_strchr/32768/0/iterations:1\n" |
| 360 | "BM_string_strchr/65536/0/iterations:1\n" |
Anders Lewis | a7b0f88 | 2017-07-24 20:01:13 -0700 | [diff] [blame] | 361 | "BM_time_clock_gettime/iterations:1\n" |
| 362 | "BM_time_clock_gettime_syscall/iterations:1\n" |
| 363 | "BM_time_gettimeofday/iterations:1\n" |
| 364 | "BM_time_gettimeofday_syscall/iterations:1\n" |
| 365 | "BM_time_time/iterations:1\n" |
| 366 | "BM_unistd_getpid/iterations:1\n" |
| 367 | "BM_unistd_getpid_syscall/iterations:1\n" |
| 368 | "BM_unistd_gettid/iterations:1\n" |
Anders Lewis | ac4f4b4 | 2017-08-08 18:29:51 -0700 | [diff] [blame] | 369 | "BM_unistd_gettid_syscall/iterations:1\n" |
| 370 | "BM_stdlib_malloc_free/8/0/iterations:1\n" |
| 371 | "BM_stdlib_malloc_free/64/0/iterations:1\n" |
| 372 | "BM_stdlib_malloc_free/512/0/iterations:1\n" |
| 373 | "BM_stdlib_malloc_free/1024/0/iterations:1\n" |
| 374 | "BM_stdlib_malloc_free/8192/0/iterations:1\n" |
| 375 | "BM_stdlib_malloc_free/16384/0/iterations:1\n" |
| 376 | "BM_stdlib_malloc_free/32768/0/iterations:1\n" |
| 377 | "BM_stdlib_malloc_free/65536/0/iterations:1\n" |
| 378 | "BM_stdlib_mbstowcs/0/0/iterations:1\n" |
| 379 | "BM_stdlib_mbrtowc/0/iterations:1\n"; |
Anders Lewis | a7b0f88 | 2017-07-24 20:01:13 -0700 | [diff] [blame] | 380 | Verify(expected, 0, std::vector<const char *>{"--bionic_xml=suites/test_full.xml", |
| 381 | "--bionic_iterations=1"}); |
| 382 | } |
| 383 | |
| 384 | TEST_F(SystemTests, small) { |
| 385 | std::string expected = |
| 386 | "BM_string_memcmp/8/8/8\n" |
| 387 | "BM_math_sqrt\n" |
| 388 | "BM_property_get/1\n"; |
| 389 | Verify(expected, 0, std::vector<const char *>{"--bionic_xml=suites/test_small.xml"}); |
| 390 | } |
| 391 | |
| 392 | TEST_F(SystemTests, medium) { |
| 393 | std::string expected = |
| 394 | "BM_string_memcmp/8/0/0/iterations:1\n" |
| 395 | "BM_string_memcmp/64/0/0/iterations:1\n" |
| 396 | "BM_string_memcmp/512/0/0/iterations:1\n" |
| 397 | "BM_string_memcmp/1024/0/0/iterations:1\n" |
| 398 | "BM_string_memcmp/8192/0/0/iterations:1\n" |
| 399 | "BM_string_memcmp/16384/0/0/iterations:1\n" |
| 400 | "BM_string_memcmp/32768/0/0/iterations:1\n" |
| 401 | "BM_string_memcmp/65536/0/0/iterations:1\n" |
| 402 | "BM_math_sqrt/iterations:1\n" |
| 403 | "BM_string_memcpy/512/4/4/iterations:25\n" |
| 404 | "BM_property_get/1/iterations:1\n"; |
| 405 | Verify(expected, 0, std::vector<const char *>{"--bionic_xml=suites/test_medium.xml", |
| 406 | "--bionic_iterations=1"}); |
| 407 | } |
| 408 | |
| 409 | TEST_F(SystemTests, from_each) { |
| 410 | std::string expected = |
| 411 | "BM_empty/iterations:1\n" |
| 412 | "BM_math_sqrt/iterations:1\n" |
| 413 | "BM_property_get/1/iterations:1\n" |
| 414 | "BM_pthread_self/iterations:1\n" |
| 415 | "BM_semaphore_sem_getvalue/iterations:1\n" |
| 416 | "BM_stdio_fread/64/iterations:1\n" |
| 417 | "BM_string_memcpy/512/4/4/iterations:1\n" |
| 418 | "BM_time_clock_gettime/iterations:1\n" |
| 419 | "BM_unistd_getpid/iterations:1\n"; |
| 420 | Verify(expected, 0, std::vector<const char *>{"--bionic_xml=suites/test_from_each.xml", |
| 421 | "--bionic_iterations=1"}); |
| 422 | } |
| 423 | |
| 424 | TEST_F(SystemTests, cmd_args) { |
| 425 | std::string expected = |
| 426 | "BM_string_memcpy/8/8/8/iterations:1\n" |
| 427 | "BM_math_log10/iterations:1\n"; |
| 428 | Verify(expected, 0, std::vector<const char *>{"--bionic_extra=BM_string_memcpy 8 8 8", |
| 429 | "--bionic_extra=BM_math_log10", |
| 430 | "--bionic_iterations=1"}); |
| 431 | } |
| 432 | |
| 433 | TEST_F(SystemTests, cmd_args_no_iter) { |
| 434 | std::string expected = |
| 435 | "BM_string_memcpy/8/8/8\n" |
| 436 | "BM_math_log10\n"; |
| 437 | Verify(expected, 0, std::vector<const char *>{"--bionic_extra=BM_string_memcpy 8 8 8", |
| 438 | "--bionic_extra=BM_math_log10"}); |
| 439 | } |
| 440 | |
| 441 | TEST_F(SystemTests, xml_and_args) { |
| 442 | std::string expected = |
| 443 | "BM_string_memcmp/8/0/0/iterations:1\n" |
| 444 | "BM_string_memcmp/64/0/0/iterations:1\n" |
| 445 | "BM_string_memcmp/512/0/0/iterations:1\n" |
| 446 | "BM_string_memcmp/1024/0/0/iterations:1\n" |
| 447 | "BM_string_memcmp/8192/0/0/iterations:1\n" |
| 448 | "BM_string_memcmp/16384/0/0/iterations:1\n" |
| 449 | "BM_string_memcmp/32768/0/0/iterations:1\n" |
| 450 | "BM_string_memcmp/65536/0/0/iterations:1\n" |
| 451 | "BM_math_sqrt/iterations:1\n" |
| 452 | "BM_string_memcpy/512/4/4/iterations:25\n" |
| 453 | "BM_property_get/1/iterations:1\n" |
| 454 | "BM_string_memcpy/8/0/0/iterations:1\n" |
| 455 | "BM_string_memcpy/64/0/0/iterations:1\n" |
| 456 | "BM_string_memcpy/512/0/0/iterations:1\n" |
| 457 | "BM_string_memcpy/1024/0/0/iterations:1\n" |
| 458 | "BM_string_memcpy/8192/0/0/iterations:1\n" |
| 459 | "BM_string_memcpy/16384/0/0/iterations:1\n" |
| 460 | "BM_string_memcpy/32768/0/0/iterations:1\n" |
| 461 | "BM_string_memcpy/65536/0/0/iterations:1\n" |
| 462 | "BM_math_log10/iterations:1\n"; |
| 463 | Verify(expected, 0, std::vector<const char *>{"--bionic_extra=BM_string_memcpy AT_ALIGNED_TWOBUF", |
| 464 | "--bionic_extra=BM_math_log10", |
| 465 | "--bionic_cpu -1", |
| 466 | "--bionic_xml=suites/test_medium.xml", |
| 467 | "--bionic_iterations=1"}); |
| 468 | } |
| 469 | |
| 470 | TEST_F(SystemTests, alignment) { |
| 471 | std::string expected = |
| 472 | "BM_string_memcmp/8/2/2/iterations:1\n" |
| 473 | "BM_string_memcmp/64/2/2/iterations:1\n" |
| 474 | "BM_string_memcmp/512/2/2/iterations:1\n" |
| 475 | "BM_string_memcmp/1024/2/2/iterations:1\n" |
| 476 | "BM_string_memcmp/8192/2/2/iterations:1\n" |
| 477 | "BM_string_memcmp/16384/2/2/iterations:1\n" |
| 478 | "BM_string_memcmp/32768/2/2/iterations:1\n" |
| 479 | "BM_string_memcmp/65536/2/2/iterations:1\n" |
| 480 | "BM_string_memcmp/8/4/4/iterations:1\n" |
| 481 | "BM_string_memcmp/64/4/4/iterations:1\n" |
| 482 | "BM_string_memcmp/512/4/4/iterations:1\n" |
| 483 | "BM_string_memcmp/1024/4/4/iterations:1\n" |
| 484 | "BM_string_memcmp/8192/4/4/iterations:1\n" |
| 485 | "BM_string_memcmp/16384/4/4/iterations:1\n" |
| 486 | "BM_string_memcmp/32768/4/4/iterations:1\n" |
| 487 | "BM_string_memcmp/65536/4/4/iterations:1\n" |
| 488 | "BM_string_memcmp/8/16/16/iterations:1\n" |
| 489 | "BM_string_memcmp/64/16/16/iterations:1\n" |
| 490 | "BM_string_memcmp/512/16/16/iterations:1\n" |
| 491 | "BM_string_memcmp/1024/16/16/iterations:1\n" |
| 492 | "BM_string_memcmp/8192/16/16/iterations:1\n" |
| 493 | "BM_string_memcmp/16384/16/16/iterations:1\n" |
| 494 | "BM_string_memcmp/32768/16/16/iterations:1\n" |
| 495 | "BM_string_memcmp/65536/16/16/iterations:1\n" |
| 496 | "BM_string_memcmp/8/512/512/iterations:1\n" |
| 497 | "BM_string_memcmp/64/512/512/iterations:1\n" |
| 498 | "BM_string_memcmp/512/512/512/iterations:1\n" |
| 499 | "BM_string_memcmp/1024/512/512/iterations:1\n" |
| 500 | "BM_string_memcmp/8192/512/512/iterations:1\n" |
| 501 | "BM_string_memcmp/16384/512/512/iterations:1\n" |
| 502 | "BM_string_memcmp/32768/512/512/iterations:1\n" |
| 503 | "BM_string_memcmp/65536/512/512/iterations:1\n" |
| 504 | "BM_string_memcmp/8/2048/2048/iterations:1\n" |
| 505 | "BM_string_memcmp/64/2048/2048/iterations:1\n" |
| 506 | "BM_string_memcmp/512/2048/2048/iterations:1\n" |
| 507 | "BM_string_memcmp/1024/2048/2048/iterations:1\n" |
| 508 | "BM_string_memcmp/8192/2048/2048/iterations:1\n" |
| 509 | "BM_string_memcmp/16384/2048/2048/iterations:1\n" |
| 510 | "BM_string_memcmp/32768/2048/2048/iterations:1\n" |
| 511 | "BM_string_memcmp/65536/2048/2048/iterations:1\n" |
| 512 | "BM_string_strlen/8/2/iterations:1\n" |
| 513 | "BM_string_strlen/64/2/iterations:1\n" |
| 514 | "BM_string_strlen/512/2/iterations:1\n" |
| 515 | "BM_string_strlen/1024/2/iterations:1\n" |
| 516 | "BM_string_strlen/8192/2/iterations:1\n" |
| 517 | "BM_string_strlen/16384/2/iterations:1\n" |
| 518 | "BM_string_strlen/32768/2/iterations:1\n" |
| 519 | "BM_string_strlen/65536/2/iterations:1\n" |
| 520 | "BM_string_strlen/8/4/iterations:1\n" |
| 521 | "BM_string_strlen/64/4/iterations:1\n" |
| 522 | "BM_string_strlen/512/4/iterations:1\n" |
| 523 | "BM_string_strlen/1024/4/iterations:1\n" |
| 524 | "BM_string_strlen/8192/4/iterations:1\n" |
| 525 | "BM_string_strlen/16384/4/iterations:1\n" |
| 526 | "BM_string_strlen/32768/4/iterations:1\n" |
| 527 | "BM_string_strlen/65536/4/iterations:1\n" |
| 528 | "BM_string_strlen/8/16/iterations:1\n" |
| 529 | "BM_string_strlen/64/16/iterations:1\n" |
| 530 | "BM_string_strlen/512/16/iterations:1\n" |
| 531 | "BM_string_strlen/1024/16/iterations:1\n" |
| 532 | "BM_string_strlen/8192/16/iterations:1\n" |
| 533 | "BM_string_strlen/16384/16/iterations:1\n" |
| 534 | "BM_string_strlen/32768/16/iterations:1\n" |
| 535 | "BM_string_strlen/65536/16/iterations:1\n" |
| 536 | "BM_string_strlen/8/512/iterations:1\n" |
| 537 | "BM_string_strlen/64/512/iterations:1\n" |
| 538 | "BM_string_strlen/512/512/iterations:1\n" |
| 539 | "BM_string_strlen/1024/512/iterations:1\n" |
| 540 | "BM_string_strlen/8192/512/iterations:1\n" |
| 541 | "BM_string_strlen/16384/512/iterations:1\n" |
| 542 | "BM_string_strlen/32768/512/iterations:1\n" |
| 543 | "BM_string_strlen/65536/512/iterations:1\n" |
| 544 | "BM_string_strlen/8/2048/iterations:1\n" |
| 545 | "BM_string_strlen/64/2048/iterations:1\n" |
| 546 | "BM_string_strlen/512/2048/iterations:1\n" |
| 547 | "BM_string_strlen/1024/2048/iterations:1\n" |
| 548 | "BM_string_strlen/8192/2048/iterations:1\n" |
| 549 | "BM_string_strlen/16384/2048/iterations:1\n" |
| 550 | "BM_string_strlen/32768/2048/iterations:1\n" |
| 551 | "BM_string_strlen/65536/2048/iterations:1\n"; |
| 552 | Verify(expected, 0, std::vector<const char *>{"--bionic_xml=suites/test_alignment.xml", |
| 553 | "--bionic_iterations=100"}); |
| 554 | } |