- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
原问题把事情复杂化了,其实问题简单多了。
我试着简单地运行现有的单元测试而不添加任何东西。在我运行的单元测试 inet/tests/unit
文件夹中:
./runtest
得到这个:
andreatino@andreatino-virtual-machine:~/Git/inet/tests/unit$ ./runtest
opp_test: extracting files from *.test files into work...
Creating Makefile in /home/andreatino/Git/inet/tests/unit/work...
Makefile created, running "make depend" to add dependencies...
Creating dependencies...
intervaltree/test.cc
In file included from /home/andreatino/Downloads/omnetpp-5.0/include/platdep/sockets.h:2:0,
from ../../../src/inet/common/precompiled.h:19,
from ../../../src/inet/common/INETDefs.h:22,
from ../../../src/inet/common/IntervalTree.h:42,
from intervaltree/test.cc:4:
/home/andreatino/Downloads/omnetpp-5.0/include/omnetpp/platdep/sockets.h:33:3: error: #error "#include <platdep/sockets.h> must precede <omnetpp.h> (and <platdep/timeutil.h> if present)"
# error "#include <platdep/sockets.h> must precede <omnetpp.h> (and <platdep/timeutil.h> if present)"
^
Makefile:122: recipe for target 'out/gcc-debug//intervaltree/test.o' failed
make: *** [out/gcc-debug//intervaltree/test.o] Error 1
这是怎么回事?
注意 实际上,您可以避免阅读原始问题。除非您对获得有关该问题的更多信息感到好奇。
我正在尝试在 INet Framework 中运行自定义测试,我正在为我正在编写的组件添加自定义测试。这些文件是 this commit 的一部分.
我正在添加一个测试:inet/tests/unit
,请查看文件结构的提交。
测试文件:
%description:
Test MacUtils in Ieee80211ac:
- Length of MU bundles is correctly computed.
%includes:
#include "ieee80211ac/MacUtilsTest.h"
%global:
using namespace ::inet::tcp::test::ieee80211ac;
%activity:
MacUtilsTest test = MacUtilsTest();
test.testMaxLengthReturned();
EV << ".\n";
%contains: stdout
l=7
.
以及包含的 header :
#ifndef __INET_IEEE80211AC_MACUTILSTEST_H
#define __INET_IEEE80211AC_MACUTILSTEST_H
#include "inet/linklayer/ieee80211/mac/IMacParameters.h"
#include "inet/linklayer/ieee80211/mac/IRateSelection.h"
#include "inet/linklayer/ieee80211/mac/AccessCategory.h"
#include "inet/linklayer/ieee80211/mac/IRateControl.h"
#include "inet/linklayer/ieee80211/mac/Ieee80211Frame_m.h"
using namespace inet::ieee80211ac;
namespace inet {
namespace ieee80211ac {
class MacUtils;
class Ieee80211acMUBundleFrame;
}
namespace test {
namespace ieee80211ac {
/**
* Tests focusing on utils on bundle messages.
*/
class MacUtilsTest
{
protected:
class DummyMacParameters : public inet::ieee80211::IMacParameters {
public:
virtual const MACAddress& getAddress() const override {}
virtual bool isEdcaEnabled() const override {return false;}
virtual simtime_t getSlotTime() const override {return 0;}
virtual simtime_t getSifsTime() const override {return 0;}
virtual simtime_t getAifsTime(inet::ieee80211::AccessCategory ac) const override {return 0;}
virtual simtime_t getEifsTime(inet::ieee80211::AccessCategory ac) const override {return 0;}
virtual simtime_t getPifsTime() const override {return 0;}
virtual simtime_t getRifsTime() const override {return 0;}
virtual int getCwMin(inet::ieee80211::AccessCategory ac) const override {return 0;}
virtual int getCwMax(inet::ieee80211::AccessCategory ac) const override {return 0;}
virtual int getCwMulticast(inet::ieee80211::AccessCategory ac) const override {return 0;}
virtual simtime_t getTxopLimit(inet::ieee80211::AccessCategory ac) const override {return 0;}
virtual int getShortRetryLimit() const override {return 0;}
virtual int getLongRetryLimit() const override {return 0;}
virtual int getRtsThreshold() const override {return 0;}
virtual simtime_t getPhyRxStartDelay() const override {return 0;}
virtual bool getUseFullAckTimeout() const override {return false;}
};
class DummyRateSelection : public inet::ieee80211::IRateSelection {
public:
virtual void setRateControl(inet::ieee80211::IRateControl *rateControl) override {}
virtual const IIeee80211Mode *getSlowestMandatoryMode() override {return nullptr;}
virtual const IIeee80211Mode *getModeForUnicastDataOrMgmtFrame(
inet::ieee80211::Ieee80211DataOrMgmtFrame *frame) override {return nullptr;}
virtual const IIeee80211Mode *getModeForMulticastDataOrMgmtFrame(
inet::ieee80211::Ieee80211DataOrMgmtFrame *frame) override {return nullptr;}
virtual const IIeee80211Mode *getModeForControlFrame(
inet::ieee80211::Ieee80211Frame *controlFrame) override {return nullptr;}
virtual const IIeee80211Mode *getResponseControlFrameMode() override {return nullptr;}
};
protected:
DummyMacParameters *macParameters = nullptr;
DummyRateSelection *rateSelection = nullptr;
MacUtils *utils = nullptr;
Ieee80211acMUBundleFrame *bundleFrame = nullptr;
protected:
virtual void initialize();
public:
MacUtilsTest();
virtual ~MacUtilsTest();
public:
void testMaxLengthReturned();
};
} // namespace ieee80211ac
} // namespace test
} // namespace inet
#endif
和实现:
#include "MacUtilsTest.h"
#include "inet/linklayer/ieee80211ac/mac/MacUtils.h"
#include "inet/linklayer/ieee80211/mac/MacUtils.h"
#include "inet/linklayer/ieee80211ac/mac/Ieee80211acFrame_m.h"
using namespace inet::ieee80211ac;
namespace inet {
namespace test {
namespace ieee80211ac {
MacUtilsTest::MacUtilsTest()
{
this->initialize();
}
MacUtilsTest::~MacUtilsTest()
{
delete this->macParameters;
delete this->rateSelection;
delete this->utils;
for (unsigned int i = 0, l = this->bundleFrame->getSingleFramesArraySize(); i < l; i++)
delete this->bundleFrame->getSingleFrames(i);
delete this->bundleFrame;
}
void MacUtilsTest::initialize()
{
this->macParameters = new MacUtilsTest::DummyMacParameters();
this->rateSelection = new MacUtilsTest::DummyRateSelection();
this->utils = new inet::ieee80211ac::MacUtils(this->macParameters, this->rateSelection);
this->bundleFrame = new Ieee80211acMUBundleFrame("MU Bundle");
Ieee80211acDataFrame* data1 = new Ieee80211acDataFrame("Data-1");
data1->setByteLength(3);
Ieee80211acDataFrame* data2 = new Ieee80211acDataFrame("Data-2");
data2->setByteLength(6);
Ieee80211acDataFrame* data3 = new Ieee80211acDataFrame("Data-3");
data3->setByteLength(7);
this->bundleFrame->setSingleFramesArraySize(3);
this->bundleFrame->setSingleFrames(0, *data1);
this->bundleFrame->setSingleFrames(0, *data2);
this->bundleFrame->setSingleFrames(0, *data3);
}
void MacUtilsTest::testMaxLengthReturned()
{
int64_t length = this->utils->getMUBundleByteLength(this->bundleFrame);
EV << "l=" << length << endl;
}
} // namespace ieee80211ac
} // namespace test
} // namespace inet
我在这里添加它们只是为了这个问题,但在我链接的提交中,您可以获得有关这些文件位置的更多信息。
然后我尝试在 unit
文件夹中运行 ./runtest
并得到这个:
andreatino@andreatino-virtual-machine:~/Git/inet/tests/unit$ ./runtest
opp_test: extracting files from *.test files into work...
Creating Makefile in /home/andreatino/Git/inet/tests/unit/work...
Makefile created, running "make depend" to add dependencies...
Creating dependencies...
IEEE80211ac_MacUtils_MUBundleLength/test.cc
In file included from /home/andreatino/Downloads/omnetpp-5.0/include/platdep/sockets.h:2:0,
from ../../../src/inet/common/precompiled.h:19,
from ../../../src/inet/common/INETDefs.h:22,
from ../../../src/inet/linklayer/ieee80211/mac/AccessCategory.h:23,
from ../../../src/inet/linklayer/ieee80211/mac/IMacParameters.h:23,
from ./lib/ieee80211ac/MacUtilsTest.h:4,
from IEEE80211ac_MacUtils_MUBundleLength/test.cc:4:
/home/andreatino/Downloads/omnetpp-5.0/include/omnetpp/platdep/sockets.h:33:3: error: #error "#include <platdep/sockets.h> must precede <omnetpp.h> (and <platdep/timeutil.h> if present)"
# error "#include <platdep/sockets.h> must precede <omnetpp.h> (and <platdep/timeutil.h> if present)"
^
In file included from IEEE80211ac_MacUtils_MUBundleLength/test.cc:4:0:
./lib/ieee80211ac/MacUtilsTest.h:10:23: error: ‘ieee80211ac’ is not a namespace-name
using namespace inet::ieee80211ac;
^
./lib/ieee80211ac/MacUtilsTest.h:10:34: error: expected namespace-name before ‘;’ token
using namespace inet::ieee80211ac;
^
./lib/ieee80211ac/MacUtilsTest.h:65:9: error: ‘MacUtils’ does not name a type
MacUtils *utils = nullptr;
^
./lib/ieee80211ac/MacUtilsTest.h:66:9: error: ‘Ieee80211acMUBundleFrame’ does not name a type
Ieee80211acMUBundleFrame *bundleFrame = nullptr;
^
./lib/ieee80211ac/MacUtilsTest.h: In member function ‘virtual const inet::MACAddress& inet::test::ieee80211ac::MacUtilsTest::DummyMacParameters::getAddress() const’:
./lib/ieee80211ac/MacUtilsTest.h:30:72: warning: no return statement in function returning non-void [-Wreturn-type]
virtual const MACAddress& getAddress() const override {}
^
IEEE80211ac_MacUtils_MUBundleLength/test.cc: At global scope:
IEEE80211ac_MacUtils_MUBundleLength/test.cc:13:25: error: ‘inet::tcp’ has not been declared
using namespace ::inet::tcp::test::ieee80211ac;
^
IEEE80211ac_MacUtils_MUBundleLength/test.cc:13:36: error: ‘ieee80211ac’ is not a namespace-name
using namespace ::inet::tcp::test::ieee80211ac;
^
IEEE80211ac_MacUtils_MUBundleLength/test.cc:13:47: error: expected namespace-name before ‘;’ token
using namespace ::inet::tcp::test::ieee80211ac;
^
IEEE80211ac_MacUtils_MUBundleLength/test.cc: In member function ‘virtual void IEEE80211ac_MacUtils_MUBundleLength::Test::activity()’:
IEEE80211ac_MacUtils_MUBundleLength/test.cc:28:1: error: ‘MacUtilsTest’ was not declared in this scope
MacUtilsTest test = MacUtilsTest();
^
IEEE80211ac_MacUtils_MUBundleLength/test.cc:28:1: note: suggested alternative:
In file included from IEEE80211ac_MacUtils_MUBundleLength/test.cc:4:0:
./lib/ieee80211ac/MacUtilsTest.h:25:7: note: ‘inet::test::ieee80211ac::MacUtilsTest’
class MacUtilsTest
^
IEEE80211ac_MacUtils_MUBundleLength/test.cc:30:1: error: ‘test’ was not declared in this scope
test.testMaxLengthReturned();
^
IEEE80211ac_MacUtils_MUBundleLength/test.cc:30:1: note: suggested alternative:
In file included from IEEE80211ac_MacUtils_MUBundleLength/test.cc:4:0:
./lib/ieee80211ac/MacUtilsTest.h:19:16: note: ‘inet::test’
namespace test {
^
Makefile:123: recipe for target 'out/gcc-debug//IEEE80211ac_MacUtils_MUBundleLength/test.o' failed
make: *** [out/gcc-debug//IEEE80211ac_MacUtils_MUBundleLength/test.o] Error 1
我不明白我做错了什么......甚至这里发生了什么......
最佳答案
从 OMNeT++ 4.2 开始 <platdep/sockets.h>
必须在 <omnetpp.h>
之前正如变更日志中提到的那样:
在 inet 中,他们通过调整 src/makefrag
来确保正确的顺序在以下提交中:
https://github.com/inet-framework/inet/commit/d9abbd1b4df5b9efcfb7a7f58e8f2223f4a91a33
因此,您必须添加 makefrag
文件与您的 Makefile
位于同一文件夹中使用以下代码:
PRECOMPILED_HEADER=<path-to-inet>/src/inet/common/precompiled.h
CFLAGS += -include $(PRECOMPILED_HEADER)
考虑更换 <path-to-inet>
通过你的路径,例如../../
更新: OMNeT++ 5.1 Preview 3 强调的变更日志,问题已解决:
Ordering of 'platdep/sockets.h' and 'omnetpp.h' is no longer important. It is recommended to include 'omnetpp.h' first.
关于c++ - 无法在 INet (OmNET++) 中运行自定义单元测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39180245/
我正在尝试连接两个表: peering_autonomoussystem.potential_internet_exchange_peering_sessions(包含 ipv4 或 ipv6 地址数
当询问给定 ip(inet 类型)是否在 inet 数组内时,我在 postgres 上遇到问题。我将逐步说明我在做什么。 首先,我创建了第一个表,它将包含要包含在 inet block 中的 IP。
我正在尝试获取我的 Elixir 项目的依赖项。我不知道 Hex 是否已关闭(今天早上我能够正常获取)。当我运行时 $ mix deps.get 我看到这个: Failed to fetch
我们在使用部署在 Glassfishv2.1 服务器上的 JAX-WS 堆栈为 WS 端点实现重新连接逻辑时发现了这个问题。我们在集群环境中部署 Web 服务。为了简化部署,我们使用 0.0.0.0
在 Ubuntu 16.04 中,我运行了 ifconfig 并在 inet addr:MY_IP 中看到了我的外部 IP。 我试图通过这些方式将它“挖掘”到一个变量中: ipa=$(ifconfig
我在地下室有一个小型 ubuntu 服务器,上面有几部自制电影。我想与我的家人分享这些视频。在我最幻想的梦想中,我会提供一个带有视频列表的网站,供您选择一个并观看。比方说,像 youtube 这样的东
我必须在 OMNeT++ 5.6.1 (Ubuntu 18.04.4) 中从 INET4 扩展 UdpBasicApp 模块并执行两个重写方法(初始化和 handleMessageWhenUp)。 这
什么地方适合表演inets:start() ? 在“applicationname_app”模块中? 在 applicationname_sup主管模块? 在从主管挂起的子进程中?\ 别的地方? (我
这个问题不太可能帮助任何 future 的访客;它仅与一个小地理区域、一个特定时刻或一个非常狭窄的情况相关,而这些情况通常不适用于互联网的全局受众。如需帮助使这个问题更广泛地适用,visit the
我刚刚写了这个片段: #include #include #include int main(void) { sockaddr_in self; hostent *he;
我需要在运行时创建一个节点,其参数与其他节点相似。为此,我在 ned 文件中创建了一个动态节点:- host_send4: meshnode { parameters:
我想将列的类型从 inet 更改为 text。所以,我执行: ALTER TABLE table ALTER COLUMN col TYPE text; 但后来我发现所有值都添加了掩码。例如:192.
#include #include #include #include #include #include #include #include #include using name
我已经启动并运行了 INET (AODV) 模拟的所有示例。我的网络由多个 AODV 路由器主机组成。 我的下一个任务是交换一些关于每个主机当前位置的自定义消息(将在一定时间后通过移动更新)。我找到的
在 httpc:request() 函数发出的 http 请求中,如何为客户端授权指定用户/密码? 最佳答案 我认为 httpc 模块没有为此提供便利。尽管如此,实现起来并不难(如果我们谈论的是基本身
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 8 年前。 Improve t
我正在使用 Erlang,需要发出高效的 HTTP 请求。 Erlang/OTP 当前的“标准”HTTP 客户端是什么? 是 inets 或 ibrowse 还是其他什么东西? 任何建议或指示表示赞赏
我想构建一个用户应用程序,它将通过 INET 套接字系列与内核部分进行交互。 JAVA 支持 INET 套接字系列吗? 最佳答案 是的,Java 支持 INET 希望以下节目对您有所帮助 import
安装 Erlang Web 1.3 并以交互模式启动后,我在日志中收到以下错误: Failed to start service: "config/inets.conf" due to: "httpd
我想使用 otp 的 httpc:request/4; 从 cowboy 发送 http post application:start(inets) 返回一个错误: error,{"no such f
我是一名优秀的程序员,十分优秀!