iodev_unittest.cc revision ea1b78a018d72fd22f5ce5650121f5e4b8325a1d
1838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid// Copyright (c) 2012 The Chromium OS Authors. All rights reserved. 2838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid// Use of this source code is governed by a BSD-style license that can be 3838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid// found in the LICENSE file. 4838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 5838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid#include <stdio.h> 6838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid#include <gtest/gtest.h> 7838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 8838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reidextern "C" { 9838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid#include "cras_iodev.h" 10838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid#include "cras_rstream.h" 11838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid#include "utlist.h" 12838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid} 13838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 14ea1b78a018d72fd22f5ce5650121f5e4b8325a1dChih-Chung Changstatic int select_node_called; 15ea1b78a018d72fd22f5ce5650121f5e4b8325a1dChih-Chung Changstatic enum CRAS_STREAM_DIRECTION select_node_direction; 16ea1b78a018d72fd22f5ce5650121f5e4b8325a1dChih-Chung Changstatic cras_node_id_t select_node_id; 17f1a7e0c094f29c16f6aa9f97d328a93769e69e5cChih-Chung Changstatic struct cras_ionode *node_selected; 186f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang 196f0a5e6a967558105f37513801af573167890f67Chih-Chung Changvoid ResetStubData() { 20ea1b78a018d72fd22f5ce5650121f5e4b8325a1dChih-Chung Chang select_node_called = 0; 216f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang} 226f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang 23838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reidnamespace { 24838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 25838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reidstatic struct timespec clock_gettime_retspec; 26838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 27838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid// Test fill_time_from_frames 28838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan ReidTEST(IoDevTestSuite, FillTimeFromFramesNormal) { 29838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid struct timespec ts; 30838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 31f880b868b8da1f20594ff271492f7055d4977bb6Dylan Reid cras_iodev_fill_time_from_frames(12000, 48000, &ts); 32838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_EQ(0, ts.tv_sec); 33838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_GE(ts.tv_nsec, 249900000); 34838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_LE(ts.tv_nsec, 250100000); 35838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid} 36838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 37838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan ReidTEST(IoDevTestSuite, FillTimeFromFramesLong) { 38838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid struct timespec ts; 39838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 40f880b868b8da1f20594ff271492f7055d4977bb6Dylan Reid cras_iodev_fill_time_from_frames(120000 - 12000, 48000, &ts); 41838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_EQ(2, ts.tv_sec); 42838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_GE(ts.tv_nsec, 249900000); 43838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_LE(ts.tv_nsec, 250100000); 44838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid} 45838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 46838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan ReidTEST(IoDevTestSuite, FillTimeFromFramesShort) { 47838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid struct timespec ts; 48838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 49f880b868b8da1f20594ff271492f7055d4977bb6Dylan Reid cras_iodev_fill_time_from_frames(12000 - 12000, 48000, &ts); 50838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_EQ(0, ts.tv_sec); 51838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_EQ(0, ts.tv_nsec); 52838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid} 53838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 54838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid// Test set_playback_timestamp. 55838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan ReidTEST(IoDevTestSuite, SetPlaybackTimeStampSimple) { 56838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid struct timespec ts; 57838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 58838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid clock_gettime_retspec.tv_sec = 1; 59838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid clock_gettime_retspec.tv_nsec = 0; 60838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid cras_iodev_set_playback_timestamp(48000, 24000, &ts); 61838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_EQ(1, ts.tv_sec); 62838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_GE(ts.tv_nsec, 499900000); 63838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_LE(ts.tv_nsec, 500100000); 64838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid} 65838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 66838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan ReidTEST(IoDevTestSuite, SetPlaybackTimeStampWrap) { 67838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid struct timespec ts; 68838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 69838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid clock_gettime_retspec.tv_sec = 1; 70838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid clock_gettime_retspec.tv_nsec = 750000000; 71838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid cras_iodev_set_playback_timestamp(48000, 24000, &ts); 72838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_EQ(2, ts.tv_sec); 73838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_GE(ts.tv_nsec, 249900000); 74838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_LE(ts.tv_nsec, 250100000); 75838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid} 76838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 77838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan ReidTEST(IoDevTestSuite, SetPlaybackTimeStampWrapTwice) { 78838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid struct timespec ts; 79838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 80838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid clock_gettime_retspec.tv_sec = 1; 81838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid clock_gettime_retspec.tv_nsec = 750000000; 82838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid cras_iodev_set_playback_timestamp(48000, 72000, &ts); 83838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_EQ(3, ts.tv_sec); 84838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_GE(ts.tv_nsec, 249900000); 85838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_LE(ts.tv_nsec, 250100000); 86838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid} 87838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 88838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid// Test set_capture_timestamp. 89838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan ReidTEST(IoDevTestSuite, SetCaptureTimeStampSimple) { 90838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid struct timespec ts; 91838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 92838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid clock_gettime_retspec.tv_sec = 1; 93838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid clock_gettime_retspec.tv_nsec = 750000000; 94838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid cras_iodev_set_capture_timestamp(48000, 24000, &ts); 95838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_EQ(1, ts.tv_sec); 96838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_GE(ts.tv_nsec, 249900000); 97838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_LE(ts.tv_nsec, 250100000); 98838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid} 99838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 100838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan ReidTEST(IoDevTestSuite, SetCaptureTimeStampWrap) { 101838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid struct timespec ts; 102838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 103838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid clock_gettime_retspec.tv_sec = 1; 104838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid clock_gettime_retspec.tv_nsec = 0; 105838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid cras_iodev_set_capture_timestamp(48000, 24000, &ts); 106838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_EQ(0, ts.tv_sec); 107838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_GE(ts.tv_nsec, 499900000); 108838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_LE(ts.tv_nsec, 500100000); 109838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid} 110838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 111838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan ReidTEST(IoDevTestSuite, SetCaptureTimeStampWrapPartial) { 112838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid struct timespec ts; 113838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 114838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid clock_gettime_retspec.tv_sec = 2; 115838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid clock_gettime_retspec.tv_nsec = 750000000; 116838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid cras_iodev_set_capture_timestamp(48000, 72000, &ts); 117838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_EQ(1, ts.tv_sec); 118838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_GE(ts.tv_nsec, 249900000); 119838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_LE(ts.tv_nsec, 250100000); 120838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid} 121838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 122838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan ReidTEST(IoDevTestSuite, TestConfigParamsOneStream) { 123838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid struct cras_iodev iodev; 124838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 125838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid memset(&iodev, 0, sizeof(iodev)); 126838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 12732771830509e3baa322a5746edb3a990ea5d631fDylan Reid iodev.buffer_size = 1024; 128838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 1292c78ba503e3c97f90d4e8b0171c8e3ac50eada42Dylan Reid cras_iodev_config_params(&iodev, 10, 3); 130838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_EQ(iodev.used_size, 10); 131838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid EXPECT_EQ(iodev.cb_threshold, 3); 132838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid} 133838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 1340534603ac205e739953e3d100d09d3a93ae93c3dDylan ReidTEST(IoDevTestSuite, TestConfigParamsOneStreamLimitThreshold) { 1350534603ac205e739953e3d100d09d3a93ae93c3dDylan Reid struct cras_iodev iodev; 1360534603ac205e739953e3d100d09d3a93ae93c3dDylan Reid 1370534603ac205e739953e3d100d09d3a93ae93c3dDylan Reid memset(&iodev, 0, sizeof(iodev)); 1380534603ac205e739953e3d100d09d3a93ae93c3dDylan Reid 1390534603ac205e739953e3d100d09d3a93ae93c3dDylan Reid iodev.buffer_size = 1024; 1400534603ac205e739953e3d100d09d3a93ae93c3dDylan Reid 1412c78ba503e3c97f90d4e8b0171c8e3ac50eada42Dylan Reid cras_iodev_config_params(&iodev, 10, 10); 1420534603ac205e739953e3d100d09d3a93ae93c3dDylan Reid EXPECT_EQ(iodev.used_size, 10); 1430534603ac205e739953e3d100d09d3a93ae93c3dDylan Reid EXPECT_EQ(iodev.cb_threshold, 5); 1440534603ac205e739953e3d100d09d3a93ae93c3dDylan Reid 1450534603ac205e739953e3d100d09d3a93ae93c3dDylan Reid iodev.direction = CRAS_STREAM_INPUT; 1462c78ba503e3c97f90d4e8b0171c8e3ac50eada42Dylan Reid cras_iodev_config_params(&iodev, 10, 10); 1470534603ac205e739953e3d100d09d3a93ae93c3dDylan Reid EXPECT_EQ(iodev.used_size, 10); 1480534603ac205e739953e3d100d09d3a93ae93c3dDylan Reid EXPECT_EQ(iodev.cb_threshold, 10); 1490534603ac205e739953e3d100d09d3a93ae93c3dDylan Reid} 1500534603ac205e739953e3d100d09d3a93ae93c3dDylan Reid 15132771830509e3baa322a5746edb3a990ea5d631fDylan ReidTEST(IoDevTestSuite, TestConfigParamsOneStreamUsedGreaterBuffer) { 15232771830509e3baa322a5746edb3a990ea5d631fDylan Reid struct cras_iodev iodev; 15332771830509e3baa322a5746edb3a990ea5d631fDylan Reid 15432771830509e3baa322a5746edb3a990ea5d631fDylan Reid memset(&iodev, 0, sizeof(iodev)); 15532771830509e3baa322a5746edb3a990ea5d631fDylan Reid 15632771830509e3baa322a5746edb3a990ea5d631fDylan Reid iodev.buffer_size = 1024; 15732771830509e3baa322a5746edb3a990ea5d631fDylan Reid 1582c78ba503e3c97f90d4e8b0171c8e3ac50eada42Dylan Reid cras_iodev_config_params(&iodev, 1280, 1400); 15932771830509e3baa322a5746edb3a990ea5d631fDylan Reid EXPECT_EQ(iodev.used_size, 1024); 16032771830509e3baa322a5746edb3a990ea5d631fDylan Reid EXPECT_EQ(iodev.cb_threshold, 512); 16132771830509e3baa322a5746edb3a990ea5d631fDylan Reid} 16232771830509e3baa322a5746edb3a990ea5d631fDylan Reid 163045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Changclass IoDevSetFormatTestSuite : public testing::Test { 164045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang protected: 165045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang virtual void SetUp() { 166045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang sample_rates_[0] = 44100; 167045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang sample_rates_[1] = 48000; 168045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang sample_rates_[2] = 0; 169045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang 170045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang channel_counts_[0] = 2; 171045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang channel_counts_[1] = 0; 172045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang 173045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang memset(&iodev_, 0, sizeof(iodev_)); 174045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang iodev_.supported_rates = sample_rates_; 175045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang iodev_.supported_channel_counts = channel_counts_; 176045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang } 177045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang 1785b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Chang virtual void TearDown() { 1795b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Chang cras_iodev_free_format(&iodev_); 1805b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Chang } 1815b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Chang 182045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang struct cras_iodev iodev_; 183045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang size_t sample_rates_[3]; 184045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang size_t channel_counts_[2]; 185045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang}; 186045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang 187045156126f648a9f0910152a66572a13447bfdc6Chih-Chung ChangTEST_F(IoDevSetFormatTestSuite, SupportedFormatSecondary) { 188045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang struct cras_audio_format fmt; 189045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang int rc; 190045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang 191045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang fmt.format = SND_PCM_FORMAT_S16_LE; 192045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang fmt.frame_rate = 48000; 193045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang fmt.num_channels = 2; 194045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang rc = cras_iodev_set_format(&iodev_, &fmt); 195045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(0, rc); 196045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(SND_PCM_FORMAT_S16_LE, fmt.format); 197045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(48000, fmt.frame_rate); 198045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(2, fmt.num_channels); 199045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang} 200045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang 201045156126f648a9f0910152a66572a13447bfdc6Chih-Chung ChangTEST_F(IoDevSetFormatTestSuite, SupportedFormatPrimary) { 202045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang struct cras_audio_format fmt; 203045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang int rc; 204045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang 205045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang fmt.format = SND_PCM_FORMAT_S16_LE; 206045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang fmt.frame_rate = 44100; 207045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang fmt.num_channels = 2; 208045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang rc = cras_iodev_set_format(&iodev_, &fmt); 209045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(0, rc); 210045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(SND_PCM_FORMAT_S16_LE, fmt.format); 211045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(44100, fmt.frame_rate); 212045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(2, fmt.num_channels); 213045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang} 214045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang 215045156126f648a9f0910152a66572a13447bfdc6Chih-Chung ChangTEST_F(IoDevSetFormatTestSuite, SupportedFormatDivisor) { 216045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang struct cras_audio_format fmt; 217045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang int rc; 218045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang 219045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang fmt.format = SND_PCM_FORMAT_S16_LE; 220045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang fmt.frame_rate = 96000; 221045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang fmt.num_channels = 2; 222045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang rc = cras_iodev_set_format(&iodev_, &fmt); 223045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(0, rc); 224045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(SND_PCM_FORMAT_S16_LE, fmt.format); 225045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(48000, fmt.frame_rate); 226045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(2, fmt.num_channels); 227045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang} 228045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang 229045156126f648a9f0910152a66572a13447bfdc6Chih-Chung ChangTEST_F(IoDevSetFormatTestSuite, UnsupportedChannelCount) { 230045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang struct cras_audio_format fmt; 231045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang int rc; 232045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang 233045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang fmt.format = SND_PCM_FORMAT_S16_LE; 234045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang fmt.frame_rate = 96000; 235045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang fmt.num_channels = 1; 236045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang rc = cras_iodev_set_format(&iodev_, &fmt); 237045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(0, rc); 238045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(SND_PCM_FORMAT_S16_LE, fmt.format); 239045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(48000, fmt.frame_rate); 240045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(2, fmt.num_channels); 241045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang} 242045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang 243045156126f648a9f0910152a66572a13447bfdc6Chih-Chung ChangTEST_F(IoDevSetFormatTestSuite, SupportedFormatFallbackDefault) { 244045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang struct cras_audio_format fmt; 245045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang int rc; 246045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang 247045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang fmt.format = SND_PCM_FORMAT_S16_LE; 248045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang fmt.frame_rate = 96008; 249045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang fmt.num_channels = 2; 250045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang rc = cras_iodev_set_format(&iodev_, &fmt); 251045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(0, rc); 252045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(SND_PCM_FORMAT_S16_LE, fmt.format); 253045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(44100, fmt.frame_rate); 254045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang EXPECT_EQ(2, fmt.num_channels); 255045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang} 256045156126f648a9f0910152a66572a13447bfdc6Chih-Chung Chang 25732a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang// The ionode that is plugged should be chosen over unplugged. 25832a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung ChangTEST(IoNodeBetter, Plugged) { 25932a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang cras_ionode a, b; 26032a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang 26132a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang a.plugged = 0; 26232a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang b.plugged = 1; 26332a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang 264f1a7e0c094f29c16f6aa9f97d328a93769e69e5cChih-Chung Chang node_selected = &a; 26531426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang 26632a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang a.plugged_time.tv_sec = 0; 26732a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang a.plugged_time.tv_usec = 1; 26832a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang b.plugged_time.tv_sec = 0; 26932a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang b.plugged_time.tv_usec = 0; 27032a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang 27132a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang a.priority = 1; 27232a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang b.priority = 0; 27332a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang 27432a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang EXPECT_FALSE(cras_ionode_better(&a, &b)); 27532a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang EXPECT_TRUE(cras_ionode_better(&b, &a)); 27632a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang} 27732a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang 27831426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang// The ionode both plugged, tie should be broken by selected. 27931426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung ChangTEST(IoNodeBetter, Selected) { 28032a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang cras_ionode a, b; 28132a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang 28232a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang a.plugged = 1; 28332a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang b.plugged = 1; 28432a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang 285f1a7e0c094f29c16f6aa9f97d328a93769e69e5cChih-Chung Chang node_selected = &b; 28631426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang 28731426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang a.priority = 1; 28831426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang b.priority = 0; 28931426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang 29031426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang a.plugged_time.tv_sec = 0; 29131426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang a.plugged_time.tv_usec = 1; 29231426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang b.plugged_time.tv_sec = 0; 29331426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang b.plugged_time.tv_usec = 0; 29431426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang 29531426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang EXPECT_FALSE(cras_ionode_better(&a, &b)); 29631426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang EXPECT_TRUE(cras_ionode_better(&b, &a)); 29731426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang} 29831426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang 29931426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang// Two ionode both plugged and selected, tie should be broken by priority. 30031426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung ChangTEST(IoNodeBetter, Priority) { 30131426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang cras_ionode a, b; 30231426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang 30331426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang a.plugged = 1; 30431426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang b.plugged = 1; 30531426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang 306f1a7e0c094f29c16f6aa9f97d328a93769e69e5cChih-Chung Chang node_selected = NULL; 30731426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang 30832a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang a.priority = 0; 30932a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang b.priority = 1; 31032a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang 31132a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang a.plugged_time.tv_sec = 0; 31232a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang a.plugged_time.tv_usec = 1; 31332a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang b.plugged_time.tv_sec = 0; 31432a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang b.plugged_time.tv_usec = 0; 31532a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang 31632a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang EXPECT_FALSE(cras_ionode_better(&a, &b)); 31732a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang EXPECT_TRUE(cras_ionode_better(&b, &a)); 31832a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang} 31932a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang 32032a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang// Two ionode both plugged and have the same priority, tie should be broken 32132a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang// by plugged time. 32231426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung ChangTEST(IoNodeBetter, RecentlyPlugged) { 32332a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang cras_ionode a, b; 32432a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang 32532a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang a.plugged = 1; 32632a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang b.plugged = 1; 32732a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang 328f1a7e0c094f29c16f6aa9f97d328a93769e69e5cChih-Chung Chang node_selected = NULL; 32931426461ec77c5a7ee613d52d0a93db6b68e7b7cChih-Chung Chang 33032a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang a.priority = 1; 33132a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang b.priority = 1; 33232a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang 33332a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang a.plugged_time.tv_sec = 0; 33432a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang a.plugged_time.tv_usec = 0; 33532a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang b.plugged_time.tv_sec = 0; 33632a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang b.plugged_time.tv_usec = 1; 33732a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang 33832a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang EXPECT_FALSE(cras_ionode_better(&a, &b)); 33932a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang EXPECT_TRUE(cras_ionode_better(&b, &a)); 34032a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang} 34132a79c991ade23beeb5725ef30ee064d9eccdc07Chih-Chung Chang 3426f0a5e6a967558105f37513801af573167890f67Chih-Chung Changstatic void update_active_node(struct cras_iodev *iodev) 3436f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang{ 3446f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang} 3456f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang 3466f0a5e6a967558105f37513801af573167890f67Chih-Chung ChangTEST(IoNodePlug, ClearSelection) { 3476f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang struct cras_iodev iodev; 3486f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang struct cras_ionode ionode; 3496f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang 350786f9d1938966af8e1eb9f60559a3535b5c71ff8Chih-Chung Chang ionode.dev = &iodev; 3516f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang iodev.direction = CRAS_STREAM_INPUT; 3526f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang iodev.update_active_node = update_active_node; 3536f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang ResetStubData(); 354786f9d1938966af8e1eb9f60559a3535b5c71ff8Chih-Chung Chang cras_iodev_set_node_attr(&ionode, IONODE_ATTR_PLUGGED, 1); 3556f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang 356ea1b78a018d72fd22f5ce5650121f5e4b8325a1dChih-Chung Chang EXPECT_EQ(1, select_node_called); 357ea1b78a018d72fd22f5ce5650121f5e4b8325a1dChih-Chung Chang EXPECT_EQ(CRAS_STREAM_INPUT, select_node_direction); 358ea1b78a018d72fd22f5ce5650121f5e4b8325a1dChih-Chung Chang EXPECT_EQ(0, select_node_id); 3596f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang} 3606f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang 361838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reidextern "C" { 362838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 363838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid// From libpthread. 364838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reidint pthread_create(pthread_t *thread, const pthread_attr_t *attr, 365838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid void *(*start_routine)(void*), void *arg) { 366838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid return 0; 367838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid} 368838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 369838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reidint pthread_join(pthread_t thread, void **value_ptr) { 370838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid return 0; 371838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid} 372838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 373838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid// From librt. 374838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reidint clock_gettime(clockid_t clk_id, struct timespec *tp) { 375838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid tp->tv_sec = clock_gettime_retspec.tv_sec; 376838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid tp->tv_nsec = clock_gettime_retspec.tv_nsec; 377838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid return 0; 378838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid} 379838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 380386ab71e324831d632544f8bcecc8d0ba1890f01Dylan Reid// From cras_system_state. 381386ab71e324831d632544f8bcecc8d0ba1890f01Dylan Reidvoid cras_system_state_stream_added() { 382386ab71e324831d632544f8bcecc8d0ba1890f01Dylan Reid} 383386ab71e324831d632544f8bcecc8d0ba1890f01Dylan Reid 384386ab71e324831d632544f8bcecc8d0ba1890f01Dylan Reidvoid cras_system_state_stream_removed() { 385386ab71e324831d632544f8bcecc8d0ba1890f01Dylan Reid} 386386ab71e324831d632544f8bcecc8d0ba1890f01Dylan Reid 3875b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Chang// From cras_dsp 3885b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Changstruct cras_dsp_context *cras_dsp_context_new(int channels, int sample_rate, 3895b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Chang const char *purpose) 3905b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Chang{ 3915b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Chang return NULL; 3925b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Chang} 3935b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Chang 3945b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Changvoid cras_dsp_context_free(struct cras_dsp_context *ctx) 3955b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Chang{ 3965b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Chang} 3975b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Chang 3985b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Changvoid cras_dsp_load_pipeline(struct cras_dsp_context *ctx) 3995b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Chang{ 4005b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Chang} 4015b1717f92baa7ab7006e04431bd6b33a24d8a23fChih-Chung Chang 4027057df0d12f641d9bd9aad64d3aa09127a4e84a3Chih-Chung Changvoid cras_dsp_set_variable(struct cras_dsp_context *ctx, const char *key, 4037057df0d12f641d9bd9aad64d3aa09127a4e84a3Chih-Chung Chang const char *value) 4047057df0d12f641d9bd9aad64d3aa09127a4e84a3Chih-Chung Chang{ 4057057df0d12f641d9bd9aad64d3aa09127a4e84a3Chih-Chung Chang} 4067057df0d12f641d9bd9aad64d3aa09127a4e84a3Chih-Chung Chang 407d6957a4d295e22b427af40ff4dd29c4d14514d7fDylan Reid// From audio thread 408d6957a4d295e22b427af40ff4dd29c4d14514d7fDylan Reidint audio_thread_post_message(struct audio_thread *thread, 409d6957a4d295e22b427af40ff4dd29c4d14514d7fDylan Reid struct audio_thread_msg *msg) { 410d6957a4d295e22b427af40ff4dd29c4d14514d7fDylan Reid return 0; 411d6957a4d295e22b427af40ff4dd29c4d14514d7fDylan Reid} 412d6957a4d295e22b427af40ff4dd29c4d14514d7fDylan Reid 413ea1b78a018d72fd22f5ce5650121f5e4b8325a1dChih-Chung Changvoid cras_iodev_list_select_node(enum CRAS_STREAM_DIRECTION direction, 414ea1b78a018d72fd22f5ce5650121f5e4b8325a1dChih-Chung Chang cras_node_id_t node_id) 415f1a7e0c094f29c16f6aa9f97d328a93769e69e5cChih-Chung Chang{ 416ea1b78a018d72fd22f5ce5650121f5e4b8325a1dChih-Chung Chang select_node_called++; 417ea1b78a018d72fd22f5ce5650121f5e4b8325a1dChih-Chung Chang select_node_direction = direction; 418ea1b78a018d72fd22f5ce5650121f5e4b8325a1dChih-Chung Chang select_node_id = node_id; 419f1a7e0c094f29c16f6aa9f97d328a93769e69e5cChih-Chung Chang} 420f1a7e0c094f29c16f6aa9f97d328a93769e69e5cChih-Chung Chang 421ea1b78a018d72fd22f5ce5650121f5e4b8325a1dChih-Chung Changint cras_iodev_list_node_selected(struct cras_ionode *node) 4226f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang{ 423ea1b78a018d72fd22f5ce5650121f5e4b8325a1dChih-Chung Chang return node == node_selected; 4246f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang} 4256f0a5e6a967558105f37513801af573167890f67Chih-Chung Chang 426838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid} // extern "C" 427838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid} // namespace 428838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid 429838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reidint main(int argc, char **argv) { 430838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid ::testing::InitGoogleTest(&argc, argv); 431838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid return RUN_ALL_TESTS(); 432838597c9ca04f19584c6fbcc78ee5f417c1528bfDylan Reid} 433