storagecommands: Split validation logic
The Fru validation logic is useful in isolation, split it into a
separate library that can be included.
Tested:
[0/1] Running all tests.
1/12 phosphor-objmgr / well_known OK 0.24s
2/12 phosphor-objmgr / need_to_introspect OK 0.22s
3/12 phosphor-objmgr / name_change OK 0.16s
4/12 phosphor-objmgr / interfaces_added OK 0.13s
5/12 phosphor-objmgr / handler OK 0.09s
6/12 phosphor-objmgr / mapper OK 0.07s
7/12 phosphor-host-ipmid / entitymap_json OK 0.06s
8/12 phosphor-host-ipmid / message OK 0.05s
9/12 phosphor-host-ipmid / session/closesession OK 0.03s
10/12 phosphor-objmgr / associations OK 0.20s
11/12 phosphor-host-ipmid / dbus-sdr/sensorcommands OK 0.02s
12/12 intel-ipmi-oem / message OK 0.02s
Ok: 12
Expected Fail: 0
Fail: 0
Unexpected Pass: 0
Skipped: 0
Timeout: 0
Change-Id: I9130eb81703b0cda7c3229f16cd689dd2c96c55c
Signed-off-by: Peter Foley <pefoley@google.com>
diff --git a/include/fruutils.hpp b/include/fruutils.hpp
new file mode 100644
index 0000000..f830b71
--- /dev/null
+++ b/include/fruutils.hpp
@@ -0,0 +1,24 @@
+/*
+// Copyright (c) 2022-2023 Intel Corporation
+//
+// 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.
+*/
+
+#pragma once
+
+#include <cstdint>
+#include <vector>
+
+// Validate the vector holds a complete FRU's contents.
+bool validateBasicFruContent(const std::vector<uint8_t>& fru,
+ size_t lastWriteAddr);