summaryrefslogtreecommitdiff
path: root/raw_os.cpp
diff options
context:
space:
mode:
authormukesh agrawal <quiche@google.com>2016-09-30 19:04:33 -0700
committermukesh agrawal <quiche@google.com>2016-10-04 18:30:29 -0700
commitec533e0f59b7e88bac734d538f596ab095bc74ca (patch)
treeb33c598f6bf378418f78be7406c3c24afbf21932 /raw_os.cpp
parent0da05477c58df736e69ec421d14a1c3216011d81 (diff)
downloadwifilogd-ec533e0f59b7e88bac734d538f596ab095bc74ca.tar.gz
add OS abstraction
Add the Os class, which abstracts the clock_gettime() call. (Additionally methods will be added over time.) Additionally: - Add the MockOs class, so that other classes can be tested in isolation from the underlying system. - Add the RawOs class, to test the logic within the Os class itself. - Add unit tests for the Os class. Bug: 31862754 Test: ./runtests.sh (on bullhead) Change-Id: Ic40e09439966d74b1e470bcfd66d8c8e74157137
Diffstat (limited to 'raw_os.cpp')
-rw-r--r--raw_os.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/raw_os.cpp b/raw_os.cpp
new file mode 100644
index 0000000..03064d8
--- /dev/null
+++ b/raw_os.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 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 <time.h>
+
+#include "wifilogd/raw_os.h"
+
+namespace android {
+namespace wifilogd {
+
+RawOs::RawOs() {}
+RawOs::~RawOs() {}
+
+// All methods in RawOs should be thin wrappers over library/system calls.
+// In particular, the methods in RawOs should not have any logic in them.
+// Instead, all logic should be placed in Os, so that said logic can be tested.
+
+int RawOs::ClockGettime(clockid_t clock_id, struct timespec* ts) const {
+ return clock_gettime(clock_id, ts);
+}
+
+} // namespace wifilogd
+} // namespace android